MCPcopy
hub / github.com/perkeep/perkeep / TestKeywords

Function TestKeywords

pkg/search/predicate_test.go:625–650  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

623}
624
625func TestKeywords(t *testing.T) {
626 cj := func(c *Constraint) []byte {
627 v, err := json.MarshalIndent(c, "", " ")
628 if err != nil {
629 t.Fatal(err)
630 }
631 return v
632 }
633 for _, tt := range keywordTests {
634 got, err := tt.object.Predicate(tt.ctx, tt.args)
635 if err != nil {
636 if tt.errContains != "" && strings.Contains(err.Error(), tt.errContains) {
637 continue
638 }
639 t.Errorf("%v: %#v(%q) error: %v, but wanted an error containing: %v", tt.name, tt.object, tt.args, err, tt.errContains)
640 continue
641 }
642 if tt.errContains != "" {
643 t.Errorf("%v: %#v(%q) succeeded; want error containing %q", tt.name, tt.object, tt.args, tt.errContains)
644 continue
645 }
646 if !reflect.DeepEqual(got, tt.want) {
647 t.Errorf("%v: %#v(%q) got:\n%s\n\nwant:%s\n", tt.name, tt.object, tt.args, cj(got), cj(tt.want))
648 }
649 }
650}
651
652func TestParseWHExpression(t *testing.T) {
653 tests := []struct {

Callers

nothing calls this directly

Calls 4

FatalMethod · 0.80
ContainsMethod · 0.80
PredicateMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected