Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions apis/filters/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,50 @@ func TestArgsMatchKVList(t *testing.T) {
}
}
}

func TestArgsValidate(t *testing.T) {
tests := []struct {
name string
testArgs Args
accepted map[string]bool
wantErr bool
}{
{
name: "mapping keys are in the accepted set",
testArgs: Args{
map[string]map[string]bool{
"created": {
"today": true,
},
},
},
accepted: map[string]bool{
"created": true,
},
wantErr: false,
},
{
name: "mapping keys are not in the accepted set",
testArgs: Args{
map[string]map[string]bool{
"created": {
"today": true,
},
},
},
accepted: map[string]bool{
"created": false,
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.testArgs.Validate(tt.accepted)
if (err != nil) != tt.wantErr {
t.Errorf("Validate() error = %v, wantErr %v", err, tt.wantErr)
return
}
})
}
}