From 0e15ef497a81a8659456a8dcd824baa63d08dc36 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Tue, 10 Mar 2020 10:21:03 -0700 Subject: [PATCH] Added test for issue #39 --- commands_test.go | 12 ++++++++++++ testdata/issue39 | 6 ++++++ 2 files changed, 18 insertions(+) create mode 100644 testdata/issue39 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