1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package host
- import (
- "net"
- "os"
- "testing"
- )
- func TestHost(t *testing.T) {
- host := New()
- var ips []net.IP
- hostname, _ := os.Hostname()
- if err := host.SetService(""); err == nil {
- t.Fatal("Not expecting empty service name to be valid")
- }
- if err := host.SetService("service"); err != nil {
- t.Fatal(err)
- }
- if err := host.SetHostname(hostname); err == nil {
- t.Fatal("Hostname should contain trailing .")
- }
- if err := host.SetHostname(hostname + "."); err != nil {
- t.Fatal(err)
- }
- if err := host.SetDomain("local"); err == nil {
- t.Fatal("Domain should contain trailing .")
- }
- if err := host.SetDomain("local."); err != nil {
- t.Fatal(err)
- }
- if err := host.SetIPs(ips); err != nil {
- t.Fatal(err)
- }
- if err := host.SetPort(0); err == nil {
- t.Fatal("Port should not be 0 or less")
- }
- if err := host.SetPort(4545); err != nil {
- t.Fatal(err)
- }
- t.Log(host.String())
- }
|