Skip to content

Commit

Permalink
Fixed TestFileExistsLocally tests in common/config_test.go so that th…
Browse files Browse the repository at this point in the history
…ey're actually being run. Added a non-existent-protocol:// test.
  • Loading branch information
arizvisa committed Feb 3, 2018
1 parent c366a1e commit efc97db
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions common/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand Down

0 comments on commit efc97db

Please sign in to comment.