-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatchers_not_test.go
41 lines (38 loc) · 1.04 KB
/
matchers_not_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package justest_test
import (
"testing"
. "github.com/arikkfir/justest"
)
func TestNot(t *testing.T) {
type testCase struct {
actuals []any
matcher MatcherFunc
verifier TestOutcomeVerifier
}
testCases := map[string]testCase{
"Failed matcher succeeds": {
actuals: []any{"foo-bar"},
matcher: MatcherFunc(func(t T, actual ...any) { t.Fatalf("should be ignored"); panic("unreachable") }),
verifier: SuccessVerifier(),
},
"Successful matcher fails": {
actuals: []any{"foo-bar"},
matcher: MatcherFunc(func(t T, actual ...any) {}),
verifier: FailureVerifier(`Expected mismatch did not happen`),
},
"Panicking matcher re-panics": {
actuals: []any{"foo-bar"},
matcher: MatcherFunc(func(t T, actual ...any) { panic("panic propagated") }),
verifier: PanicVerifier(`panic propagated`),
},
}
for name, tc := range testCases {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
mt := NewMockT(t)
defer mt.Verify(tc.verifier)
With(mt).VerifyThat(tc.actuals...).Will(Not(tc.matcher)).Now()
})
}
}