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 3, 2023
1 parent 0c8ea19 commit f932268
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 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)
// 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", absPath)
}

0 comments on commit f932268

Please sign in to comment.