Skip to content

Commit 7267e0f

Browse files
authored
Fix import tests windows (#6412)
* use path.join to create dir path * add eol rule for txtar files in .gitattributes
1 parent 91ea77d commit 7267e0f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
pkg/operator/crds/*.yaml linguist-generated=true
2+
3+
*.txtar text eol=lf

pkg/flow/import_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"io/fs"
66
"os"
7+
"path"
78
"strings"
89
"sync"
910
"testing"
@@ -73,7 +74,7 @@ func buildTestImportFile(t *testing.T, filename string) testImportFile {
7374
func TestImportFile(t *testing.T) {
7475
directory := "./testdata/import_file"
7576
for _, file := range getTestFiles(directory, t) {
76-
tc := buildTestImportFile(t, directory+"/"+file.Name())
77+
tc := buildTestImportFile(t, path.Join(directory, file.Name()))
7778
t.Run(tc.description, func(t *testing.T) {
7879
defer os.Remove("module.river")
7980
require.NoError(t, os.WriteFile("module.river", []byte(tc.module), 0664))
@@ -100,7 +101,7 @@ func TestImportFile(t *testing.T) {
100101
func TestImportString(t *testing.T) {
101102
directory := "./testdata/import_string"
102103
for _, file := range getTestFiles(directory, t) {
103-
archive, err := txtar.ParseFile(directory + "/" + file.Name())
104+
archive, err := txtar.ParseFile(path.Join(directory, file.Name()))
104105
require.NoError(t, err)
105106
t.Run(archive.Files[0].Name, func(t *testing.T) {
106107
testConfig(t, string(archive.Files[0].Data), "", nil)
@@ -133,7 +134,7 @@ func buildTestImportError(t *testing.T, filename string) testImportError {
133134
func TestImportError(t *testing.T) {
134135
directory := "./testdata/import_error"
135136
for _, file := range getTestFiles(directory, t) {
136-
tc := buildTestImportError(t, directory+"/"+file.Name())
137+
tc := buildTestImportError(t, path.Join(directory, file.Name()))
137138
t.Run(tc.description, func(t *testing.T) {
138139
testConfigError(t, tc.main, strings.TrimRight(tc.expectedError, "\n"))
139140
})

0 commit comments

Comments
 (0)