Skip to content

Commit

Permalink
Fix missing windows test case, fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cbednarski committed Mar 7, 2020
1 parent aecfa8f commit a343a8e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

type Options struct {
Preview bool
Preview bool
}

// PrintErrLn will print to stderr followed by a newline
Expand Down
12 changes: 11 additions & 1 deletion hostess/hostfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 2 additions & 4 deletions hostess/hostlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)))
}
}

Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func wrappedMain(args []string) error {
}

options := &Options{
Preview: *preview,
Preview: *preview,
}

command := cli.Arg(0)
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a343a8e

Please sign in to comment.