Skip to content

Commit 6b91e84

Browse files
committed
fieldfilter_test.go: improved TestSelect test
1 parent 562cd58 commit 6b91e84

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/datagatherer/k8s/fieldfilter_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,19 @@ func TestSelect(t *testing.T) {
120120
"route": {routeResource, routeFieldsToSelect, routeExpectedJSON},
121121
}
122122

123-
for resource, test := range tests {
123+
for name, test := range tests {
124124
err := Select(test.fieldsToSelect, test.resource)
125125
if err != nil {
126126
t.Fatalf("unexpected error: %s", err)
127127
}
128128

129129
bytes, err := json.MarshalIndent(test.resource, "", " ")
130130

131-
if string(bytes) != test.expectedJSON {
132-
t.Fatalf("%s test failed, unexpected JSON: \ngot \n%s\nwant\n%s", resource, string(bytes), test.expectedJSON)
133-
}
131+
t.Run(name, func(t *testing.T) {
132+
if string(bytes) != test.expectedJSON {
133+
t.Fatalf("unexpected JSON: \ngot \n%s\nwant\n%s", string(bytes), test.expectedJSON)
134+
}
135+
})
134136
}
135137
}
136138

0 commit comments

Comments
 (0)