Skip to content

Commit

Permalink
convert windows file path to file uri in TestVerifiedHash
Browse files Browse the repository at this point in the history
this fixes the following unit test failure on windows:
```
=== RUN   TestVerifiedHash
    metadata_test.go:214:
        	Error Trace:	D:/a/crc/crc/pkg/crc/machine/bundle/metadata_test.go:214
        	            				D:/a/crc/crc/pkg/crc/machine/bundle/metadata_test.go:193
        	Error:      	Received unexpected error:
        	            	parse "file://D:\\a\\crc\\crc\\pkg\\crc\\machine\\bundle\\testdata\\sha256sum_correct_4.13.0.txt.sig": invalid port ":\\a\\crc\\crc\\pkg\\crc\\machine\\bundle\\testdata\\sha256sum_correct_4.13.0.txt.sig" after host
        	Test:       	TestVerifiedHash
```

the correct file URI should be 'file://D/a/crc/crc/pkg/crc/machine/bundle..'
  • Loading branch information
anjannath committed Oct 5, 2023
1 parent d241e3f commit 56cc93d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/crc/machine/bundle/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,9 @@ func TestVerifiedHash(t *testing.T) {
func testDataURI(t *testing.T, sha256sum string) string {
absPath, err := filepath.Abs(filepath.Join("testdata", sha256sum))
require.NoError(t, err)
return fmt.Sprintf("file:///%s", absPath)
// when its a windows path with drive letter
if volume := filepath.VolumeName(absPath); volume != "" {
return fmt.Sprintf("file://%s/%s", volume[:1], absPath[3:])
}
return fmt.Sprintf("file:///%s", filepath.ToSlash(absPath))
}

0 comments on commit 56cc93d

Please sign in to comment.