diff --git a/internal/filter/parser_test.go b/internal/filter/parser_test.go index b950adc6a..72a88f177 100644 --- a/internal/filter/parser_test.go +++ b/internal/filter/parser_test.go @@ -1,6 +1,7 @@ package filter import ( + "github.com/davecgh/go-spew/spew" "github.com/stretchr/testify/assert" "strings" "testing" @@ -322,10 +323,35 @@ func FuzzParser(f *testing.F) { f.Add("col%29umn>val%29ue") f.Fuzz(func(t *testing.T, expr string) { - _, err := ParseFilter(expr) + f, err := ParseFilter(expr) if strings.Count(expr, "(") != strings.Count(expr, ")") { assert.Error(t, err) } + + if err == nil { + dump := spew.Sdump(f) + + assertDumpContainsAny := func(substrs ...string) { + for _, substr := range substrs { + if strings.Contains(dump, substr) { + return + } + } + + assert.Failf(t, "Parsed expression dump did not contain any expected string", + "Expression: %q\nExpected: %#v\n\n%s", expr, substrs, dump) + } + + if strings.Contains(expr, "&") { + assertDumpContainsAny("All") + } + if strings.Contains(expr, "|") { + assertDumpContainsAny("Any", "None") + } + if strings.Contains(expr, "!") { + assertDumpContainsAny("None", "UnEqual", "Unlike") + } + } }) }