diff --git a/apis/filters/parse_test.go b/apis/filters/parse_test.go index c7b7e89a3..fc83a9caf 100644 --- a/apis/filters/parse_test.go +++ b/apis/filters/parse_test.go @@ -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 + } + }) + } +}