Skip to content

Commit

Permalink
test: add test cases for parse_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
WillSmisi committed Dec 22, 2018
1 parent 68519ab commit 402996e
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions apis/filters/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,54 @@ func TestArgsMatchKVList(t *testing.T) {
}
}
}

func TestArgsValidate(t *testing.T) {
tests := []struct {
name string
testArgs Args
accepted map[string]bool
wantErr bool
}{
{
"mapping keys are in the accepted set",
Args{
map[string]map[string]bool{
"created": {
"today": true,
},
},
},

map[string]bool{
"created": true,
},

false,
},
{
"mapping keys are not in the accepted set",
Args{
map[string]map[string]bool{
"created": {
"today": true,
},
},
},

map[string]bool{
"created": false,
},

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
}
})
}
}

0 comments on commit 402996e

Please sign in to comment.