2015-02-24 10:15:23 +00:00
|
|
|
package hostess_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/cbednarski/hostess"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2015-02-24 10:17:01 +00:00
|
|
|
func TestHostname(t *testing.T) {
|
|
|
|
|
|
|
|
h := hostess.Hostname{}
|
|
|
|
h.Domain = domain
|
|
|
|
h.Ip = ip
|
|
|
|
h.Enabled = enabled
|
|
|
|
|
|
|
|
if h.Domain != domain {
|
|
|
|
t.Errorf("Domain should be %s", domain)
|
|
|
|
}
|
2015-02-24 12:17:31 +00:00
|
|
|
if !h.Ip.Equal(ip) {
|
|
|
|
t.Errorf("Ip should be %s", ip)
|
2015-02-24 10:17:01 +00:00
|
|
|
}
|
|
|
|
if h.Enabled != enabled {
|
|
|
|
t.Errorf("Enabled should be %s", enabled)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-24 10:15:23 +00:00
|
|
|
func TestFormatHostname(t *testing.T) {
|
2015-02-24 12:17:31 +00:00
|
|
|
hostname := &hostess.Hostname{domain, ip, enabled, false}
|
2015-02-24 10:15:23 +00:00
|
|
|
|
|
|
|
const exp_enabled = "127.0.0.1 localhost"
|
|
|
|
if hostname.Format() != exp_enabled {
|
|
|
|
t.Errorf(asserts, hostname.Format(), exp_enabled)
|
|
|
|
}
|
|
|
|
|
|
|
|
hostname.Enabled = false
|
|
|
|
const exp_disabled = "# 127.0.0.1 localhost"
|
|
|
|
if hostname.Format() != exp_disabled {
|
|
|
|
t.Errorf(asserts, hostname.Format(), exp_disabled)
|
|
|
|
}
|
|
|
|
}
|