From 5f9fb2cb8d55003b2da8f406e22a4705b08d471e Mon Sep 17 00:00:00 2001 From: Christie Wilson Date: Tue, 17 Jul 2018 17:21:51 -0700 Subject: [PATCH] Fix remote URL test (#237) When this test was originally created, an HTTP get to `https://url.com/something/not/real` probably failed, but now it will return a `503`, i.e. the `http.Get` call will succeed. This test will now use a URL which should not reasonable ever succeed (famous last words). Alternatively we could use dependency injection and mock `http.Get` but it doesn't seem worth it. This commit also updates the test to use `Run` to run each test in the table test as a separate test so we can get a clear indication which cases fail and which succeed. --- pkg/util/command_util_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/util/command_util_test.go b/pkg/util/command_util_test.go index 6ddf8c3b9..905460686 100644 --- a/pkg/util/command_util_test.go +++ b/pkg/util/command_util_test.go @@ -375,27 +375,33 @@ func Test_ResolveSources(t *testing.T) { } var testRemoteUrls = []struct { + name string url string valid bool }{ { + name: "Valid URL", url: testUrl, valid: true, }, { + name: "Invalid URL", url: "not/real/", valid: false, }, { - url: "https://url.com/something/not/real", + name: "URL which fails on GET", + url: "https://thereisnowaythiswilleverbearealurlrightrightrightcatsarethebest.com/something/not/real", valid: false, }, } func Test_RemoteUrls(t *testing.T) { for _, test := range testRemoteUrls { - valid := IsSrcRemoteFileURL(test.url) - testutil.CheckErrorAndDeepEqual(t, false, nil, test.valid, valid) + t.Run(test.name, func(t *testing.T) { + valid := IsSrcRemoteFileURL(test.url) + testutil.CheckErrorAndDeepEqual(t, false, nil, test.valid, valid) + }) } }