Skip to content

Commit 67bf6a8

Browse files
committed
Add name to test cases
1 parent 4ed148f commit 67bf6a8

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

hooks/jsonnet-fmt-hook/main_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,19 @@ func TestExecJsonnetFmt(t *testing.T) {
9595
invalidJsonnetFile := testutil.CreateJsonnet(t, tempDir, "invalid.jsonnet", testutil.InvalidJsonnetBody)
9696

9797
params := []struct {
98+
name string
9899
f string
99100
opts []string
100101
wantErr error
101102
}{
102103
{
104+
name: "normal case",
103105
f: jsonnetFile,
104106
opts: nil,
105107
wantErr: nil,
106108
},
107109
{
110+
name: "missing a trailing comma should be fixed",
108111
f: malformedjsonnetFile,
109112
opts: []string{"--test"},
110113
wantErr: &FmtError{
@@ -122,11 +125,13 @@ func TestExecJsonnetFmt(t *testing.T) {
122125
},
123126
},
124127
{
128+
name: "execute with -i option",
125129
f: testutil.CreateJsonnet(t, tempDir, "in-place.jsonnet", testutil.MalformedJsonnetBody),
126130
opts: []string{"-i"},
127131
wantErr: nil,
128132
},
129133
{
134+
name: "should be failed to check when passing an invalid jsonnet file",
130135
f: invalidJsonnetFile,
131136
opts: []string{"--test"},
132137
wantErr: &FmtError{exitCode: 1, diff: nil},
@@ -135,7 +140,7 @@ func TestExecJsonnetFmt(t *testing.T) {
135140

136141
for _, param := range params {
137142
err := execJsonnetFmt(param.f, param.opts)
138-
baseInfo := fmt.Sprintf("params=(%q, %q)", param.f, param.opts)
143+
baseInfo := fmt.Sprintf("name=%q, params=(%q, %q)", param.name, param.f, param.opts)
139144

140145
if param.wantErr == nil {
141146
if err == nil {

0 commit comments

Comments
 (0)