From 5fa84d5658bf1de74ff6cd7b5706dd8483cbfb06 Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Wed, 9 Nov 2016 11:55:10 -0800 Subject: [PATCH] Add unit test for missing port helper func --- command/agent/config_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/command/agent/config_test.go b/command/agent/config_test.go index 40c9eca27..2c8571fa8 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -2,6 +2,7 @@ package agent import ( "io/ioutil" + "net" "os" "path/filepath" "reflect" @@ -541,3 +542,14 @@ func TestResources_ParseReserved(t *testing.T) { } } + +func TestIsMissingPort(t *testing.T) { + _, _, err := net.SplitHostPort("localhost") + if missing := isMissingPort(err); !missing { + t.Errorf("expected missing port error, but got %v", err) + } + _, _, err = net.SplitHostPort("localhost:9000") + if missing := isMissingPort(err); missing { + t.Errorf("expected no error, but got %v", err) + } +}