Skip to content

Commit acb4c57

Browse files
committed
Fix nativeimgutil_test.go on Windows with QEMU installed
On Windows both '\' and '/'` would be treated as path separators - need to replace both. Signed-off-by: Arthur Sengileyev <[email protected]>
1 parent 5288113 commit acb4c57

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

pkg/nativeimgutil/nativeimgutil_test.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,35 +61,32 @@ func TestConvertToRaw(t *testing.T) {
6161
assert.NilError(t, err)
6262

6363
t.Run("qcow without backing file", func(t *testing.T) {
64-
resultImage := filepath.Join(tmpDir, strings.ReplaceAll(t.Name(), string(os.PathSeparator), "_"))
65-
assert.NilError(t, err)
64+
resultImage := filepath.Join(tmpDir, strings.ReplaceAll(strings.ReplaceAll(t.Name(), string(os.PathSeparator), "_"), "/", "_"))
6665

6766
err = ConvertToRaw(qcowImage.Name(), resultImage, nil, false)
6867
assert.NilError(t, err)
6968
assertFileEquals(t, rawImage.Name(), resultImage)
7069
})
7170

7271
t.Run("qcow with backing file", func(t *testing.T) {
73-
resultImage := filepath.Join(tmpDir, strings.ReplaceAll(t.Name(), string(os.PathSeparator), "_"))
74-
assert.NilError(t, err)
72+
resultImage := filepath.Join(tmpDir, strings.ReplaceAll(strings.ReplaceAll(t.Name(), string(os.PathSeparator), "_"), "/", "_"))
7573

7674
err = ConvertToRaw(qcowImage.Name(), resultImage, nil, true)
7775
assert.NilError(t, err)
7876
assertFileEquals(t, rawImage.Name(), resultImage)
7977
})
8078

8179
t.Run("qcow with extra size", func(t *testing.T) {
82-
resultImage := filepath.Join(tmpDir, strings.ReplaceAll(t.Name(), string(os.PathSeparator), "_"))
83-
assert.NilError(t, err)
80+
resultImage := filepath.Join(tmpDir, strings.ReplaceAll(strings.ReplaceAll(t.Name(), string(os.PathSeparator), "_"), "/", "_"))
81+
8482
size := int64(2_097_152) // 2mb
8583
err = ConvertToRaw(qcowImage.Name(), resultImage, &size, false)
8684
assert.NilError(t, err)
8785
assertFileEquals(t, rawImageExtended.Name(), resultImage)
8886
})
8987

9088
t.Run("raw", func(t *testing.T) {
91-
resultImage := filepath.Join(tmpDir, strings.ReplaceAll(t.Name(), string(os.PathSeparator), "_"))
92-
assert.NilError(t, err)
89+
resultImage := filepath.Join(tmpDir, strings.ReplaceAll(strings.ReplaceAll(t.Name(), string(os.PathSeparator), "_"), "/", "_"))
9390

9491
err = ConvertToRaw(rawImage.Name(), resultImage, nil, false)
9592
assert.NilError(t, err)

0 commit comments

Comments
 (0)