From efc97dbda2fedd12cb8825db3cdaff2017159654 Mon Sep 17 00:00:00 2001 From: Ali Rizvi-Santiago Date: Fri, 2 Feb 2018 20:29:10 -0600 Subject: [PATCH] Fixed TestFileExistsLocally tests in common/config_test.go so that they're actually being run. Added a non-existent-protocol:// test. --- common/config_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/config_test.go b/common/config_test.go index 35697291d..29574ee4e 100644 --- a/common/config_test.go +++ b/common/config_test.go @@ -285,7 +285,7 @@ func TestDownloadableURL_FilePaths(t *testing.T) { } } -func test_FileExistsLocally(t *testing.T) { +func TestFileExistsLocally(t *testing.T) { portablepath := GetPortablePathToTestFixtures(t) dirCases := []struct { @@ -294,15 +294,17 @@ func test_FileExistsLocally(t *testing.T) { }{ // file exists locally {fmt.Sprintf("file:///%s/SomeDir/myfile.txt", portablepath), true}, - // file is not supposed to exist locally + // remote protocols short-circuit and are considered to exist locally {"https://myfile.iso", true}, + // non-existent protocols do not exist and hence fail + {"nonexistent-protocol://myfile.iso", false}, // file does not exist locally {"file:///C/i/dont/exist", false}, } // Run through test cases to make sure they all parse correctly for _, tc := range dirCases { fileOK := FileExistsLocally(tc.Input) - if !fileOK { + if fileOK != tc.Output { t.Fatalf("Test Case failed: Expected %#v, received = %#v, input = %s", tc.Output, fileOK, tc.Input) }