Skip to content

Commit 88567a0

Browse files
author
WillSmisi
committed
test: add test cases for parse_test.go
Signed-off-by: WillSmisi <[email protected]>
1 parent 68519ab commit 88567a0

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

apis/filters/parse_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,54 @@ func TestArgsMatchKVList(t *testing.T) {
223223
}
224224
}
225225
}
226+
227+
func TestArgsValidate(t *testing.T) {
228+
tests := []struct {
229+
name string
230+
testArgs Args
231+
accepted map[string]bool
232+
wantErr bool
233+
}{
234+
{
235+
"mapping keys are in the accepted set",
236+
Args{
237+
map[string]map[string]bool{
238+
"created": {
239+
"today": true,
240+
},
241+
},
242+
},
243+
244+
map[string]bool{
245+
"created": true,
246+
},
247+
248+
false,
249+
},
250+
{
251+
"mapping keys are not in the accepted set",
252+
Args{
253+
map[string]map[string]bool{
254+
"created": {
255+
"today": true,
256+
},
257+
},
258+
},
259+
260+
map[string]bool{
261+
"created": false,
262+
},
263+
264+
true,
265+
},
266+
}
267+
for _, tt := range tests {
268+
t.Run(tt.name, func(t *testing.T) {
269+
err := tt.testArgs.Validate(tt.accepted)
270+
if (err != nil) != tt.wantErr {
271+
t.Errorf("Validate() error = %v, wantErr %v", err, tt.wantErr)
272+
return
273+
}
274+
})
275+
}
276+
}

0 commit comments

Comments
 (0)