Skip to content

Commit 1bee66e

Browse files
committed
Fix problem with test symlink under msys2
When checking out the repository on windows with msys2, the symlinks are simply created as files with the path. pkg/limayaml/default.yaml -> ../../templates/default.yaml Signed-off-by: Anders F Björklund <[email protected]>
1 parent ec398e6 commit 1bee66e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

pkg/limayaml/limayaml_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
package limayaml
55

66
import (
7+
"bytes"
78
"encoding/json"
89
"os"
10+
"path/filepath"
11+
"runtime"
912
"testing"
1013

1114
"gotest.tools/v3/assert"
@@ -30,10 +33,18 @@ func TestEmptyYAML(t *testing.T) {
3033
const defaultYAML = "{}\n"
3134

3235
func TestDefaultYAML(t *testing.T) {
33-
bytes, err := os.ReadFile("default.yaml")
36+
content, err := os.ReadFile("default.yaml")
3437
assert.NilError(t, err)
38+
// if this is the unresolved symlink as a file, then make sure to resolve it
39+
if runtime.GOOS == "windows" && bytes.HasPrefix(content, []byte{'.', '.'}) {
40+
f, err := filepath.Rel(".", string(content))
41+
assert.NilError(t, err)
42+
content, err = os.ReadFile(f)
43+
assert.NilError(t, err)
44+
}
45+
3546
var y LimaYAML
36-
err = Unmarshal(bytes, &y, "")
47+
err = Unmarshal(content, &y, "")
3748
assert.NilError(t, err)
3849
y.Images = nil // remove default images
3950
y.Mounts = nil // remove default mounts

0 commit comments

Comments
 (0)