Skip to content

Commit ec44f44

Browse files
committed
test(pnpm): iterate all embedded yaml in consistency test
1 parent 430c9b4 commit ec44f44

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

module/pnpm/process_test.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import (
44
"context"
55
"embed"
66
"encoding/json"
7+
"io/fs"
8+
"sort"
9+
"strings"
710
"testing"
811

912
"github.com/stretchr/testify/assert"
@@ -13,21 +16,23 @@ import (
1316
var processTestdata embed.FS
1417

1518
func TestProcessLockfile_ConsistentAcrossMultipleRuns(t *testing.T) {
16-
testCases := []struct {
17-
name string
18-
path string
19-
}{
20-
{name: "v5-1", path: "v5/testdata/1.yaml"},
21-
{name: "v5-5", path: "v5/testdata/5.yaml"},
22-
{name: "v6-1", path: "v6/testdata/1.yaml"},
23-
{name: "v6-3", path: "v6/testdata/3.yaml"},
24-
{name: "v9-1", path: "v9/testdata/1.yaml"},
25-
{name: "v9-9", path: "v9/testdata/9.yaml"},
26-
}
19+
var testCases []string
20+
e := fs.WalkDir(processTestdata, ".", func(path string, d fs.DirEntry, walkErr error) error {
21+
if walkErr != nil {
22+
return walkErr
23+
}
24+
if d.IsDir() || !strings.HasSuffix(path, ".yaml") {
25+
return nil
26+
}
27+
testCases = append(testCases, path)
28+
return nil
29+
})
30+
assert.NoError(t, e)
31+
sort.Strings(testCases)
2732

28-
for _, tc := range testCases {
29-
t.Run(tc.name, func(t *testing.T) {
30-
data, e := processTestdata.ReadFile(tc.path)
33+
for _, testCase := range testCases {
34+
t.Run(testCase, func(t *testing.T) {
35+
data, e := processTestdata.ReadFile(testCase)
3136
assert.NoError(t, e)
3237

3338
var baseline []byte

0 commit comments

Comments
 (0)