-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatcher_test.go
36 lines (29 loc) · 1.23 KB
/
matcher_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
package matcher
import (
"context"
"github.com/stretchr/testify/assert"
"testing"
)
func TestAnythingWithInterface(t *testing.T) {
assert.False(t, AnythingWithInterface(compileTimeContextReference)(5))
assert.False(t, AnythingWithInterface(1)(5))
assert.False(t, AnythingWithInterface(1)(context.Background()))
assert.False(t, AnythingWithInterface(nil)(nil))
assert.False(t, AnythingWithInterface(1)(nil))
assert.False(t, AnythingWithInterface(nil)(1))
assert.True(t, AnythingWithInterface(compileTimeContextReference)(context.Background()))
assert.True(t, AnythingWithInterface(compileTimeContextReference)(context.TODO()))
assert.True(t, AnythingWithInterface(compileTimeContextReference)(context.WithValue(context.Background(), "foo", "bar")))
assert.True(t, AnyContext()(context.Background()))
assert.True(t, AnyContext()(context.TODO()))
}
func TestAnyContext(t *testing.T) {
assert.True(t, AnyContext()(context.Background()))
assert.True(t, AnyContext()(context.TODO()))
c, _ := context.WithCancel(context.Background())
assert.True(t, AnyContext()(c))
assert.True(t, AnyContext()(context.WithValue(c, "foo", "bar")))
assert.False(t, AnyContext()(nil))
assert.False(t, AnyContext()(""))
assert.False(t, AnyContext()(0))
}