MCPcopy Create free account
hub / github.com/daodst/chat / TestValidateConditionNegatives

Function TestValidateConditionNegatives

internal/pushrules/validate_test.go:118–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

116}
117
118func TestValidateConditionNegatives(t *testing.T) {
119 tsts := []struct {
120 Name string
121 Condition Condition
122 WantErrString string
123 }{
124 {"emptyKind", Condition{}, "invalid rule condition kind"},
125 {"invalidKind", Condition{Kind: ConditionKind("something else")}, "invalid rule condition kind"},
126 }
127 for _, tst := range tsts {
128 t.Run(tst.Name, func(t *testing.T) {
129 errs := validateCondition(&tst.Condition)
130 var foundErr error
131 for _, err := range errs {
132 t.Logf("Got error %#v", err)
133 if strings.Contains(err.Error(), tst.WantErrString) {
134 foundErr = err
135 }
136 }
137 if foundErr == nil {
138 t.Errorf("errs: got %#v, want containing %q", errs, tst.WantErrString)
139 }
140 })
141 }
142}
143
144func TestValidateConditionPositives(t *testing.T) {
145 tsts := []struct {

Callers

nothing calls this directly

Calls 4

ConditionKindTypeAlias · 0.85
validateConditionFunction · 0.85
RunMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected