mirror of https://github.com/cbednarski/hostess
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
804 B
Go
40 lines
804 B
Go
package hostess_test
|
|
|
|
import (
|
|
"github.com/cbednarski/hostess"
|
|
"testing"
|
|
)
|
|
|
|
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)
|
|
}
|
|
if !h.Ip.Equal(ip) {
|
|
t.Errorf("Ip should be %s", ip)
|
|
}
|
|
if h.Enabled != enabled {
|
|
t.Errorf("Enabled should be %s", enabled)
|
|
}
|
|
}
|
|
|
|
func TestFormatHostname(t *testing.T) {
|
|
hostname := &hostess.Hostname{domain, ip, enabled, false}
|
|
|
|
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)
|
|
}
|
|
}
|