Fix missing windows test case, fmt

master
Chris Bednarski 4 years ago
parent aecfa8f689
commit a343a8e07f

@ -12,7 +12,7 @@ import (
)
type Options struct {
Preview bool
Preview bool
}
// PrintErrLn will print to stderr followed by a newline

@ -61,12 +61,22 @@ func TestFormatHostfile(t *testing.T) {
// 1. We want localhost entries at the top
// 2. The rest are sorted by IP as STRINGS, not numeric values, so 10
// precedes 8
const expected = `127.0.0.1 localhost devsite
expected := `127.0.0.1 localhost devsite
127.0.1.1 ip-10-37-12-18
# 8.8.8.8 google.com
10.37.12.18 devsite.com m.devsite.com
`
if runtime.GOOS == "windows" {
expected = `127.0.0.1 localhost
127.0.0.1 devsite
127.0.1.1 ip-10-37-12-18
# 8.8.8.8 google.com
10.37.12.18 devsite.com
10.37.12.18 m.devsite.com
`
}
hostfile := hostess.NewHostfile()
hostfile.Path = "./hosts"
hostfile.Hosts.Add(hostess.MustHostname("localhost", "127.0.0.1", true))

@ -107,7 +107,6 @@ func TestFormatLinux(t *testing.T) {
t.Fatal(errs)
}
expected, err := ioutil.ReadFile(filepath.Join("testdata", "expected-linux"))
if err != nil {
t.Fatal(err)
@ -116,7 +115,7 @@ func TestFormatLinux(t *testing.T) {
output := hostfile.Hosts.FormatLinux()
if !bytes.Equal(output, expected) {
t.Errorf("---- Expected ----\n%s\n---- Found----\n%s\n", expected, output)
t.Error(Diff(string(expected), string(output)))
}
}
@ -138,11 +137,10 @@ func TestFormatWindows(t *testing.T) {
output := hostfile.Hosts.FormatWindows()
if !bytes.Equal(output, expected) {
t.Errorf("---- Expected ----\n%s\n---- Found----\n%s\n", expected, output)
t.Error(Diff(string(expected), string(output)))
}
}
func TestFormat(t *testing.T) {
hosts := hostess.NewHostlist()
hosts.Add(hostess.MustHostname(domain, ip, false))

@ -75,7 +75,7 @@ func wrappedMain(args []string) error {
}
options := &Options{
Preview: *preview,
Preview: *preview,
}
command := cli.Arg(0)

@ -164,7 +164,7 @@ ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
`
if runtime.GOOS== "windows" {
if runtime.GOOS == "windows" {
expected = `127.0.0.1 localhost
127.0.1.1 ubuntu
::1 ip6-localhost

Loading…
Cancel
Save