diff --git a/commands_test.go b/commands_test.go index 18a2d24..465322c 100644 --- a/commands_test.go +++ b/commands_test.go @@ -1,6 +1,8 @@ package main import ( + "os" + "path/filepath" "testing" ) @@ -24,3 +26,13 @@ func TestStrPadRight(t *testing.T) { } } } + +func TestLoadHostfile(t *testing.T) { + // Issue #39: This hosts file contains a duplicate. We should paper over it. + os.Setenv("HOSTESS_PATH", filepath.Join("testdata", "issue39")) + defer os.Unsetenv("HOSTESS_PATH") + + if _, err := LoadHostfile(); err != nil { + t.Fatal(err) + } +} diff --git a/testdata/issue39 b/testdata/issue39 new file mode 100644 index 0000000..1bb4b04 --- /dev/null +++ b/testdata/issue39 @@ -0,0 +1,6 @@ +127.0.0.1 localhost kubernetes.docker.internal +::1 localhost +# Added by Docker Desktop +# To allow the same kube context to work on the host and the container: +127.0.0.1 kubernetes.docker.internal +# End of section