-
Notifications
You must be signed in to change notification settings - Fork 13
/
subscription_test.go
46 lines (38 loc) · 1.12 KB
/
subscription_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
42
43
44
45
46
package vega
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/vektra/neko"
)
func TestSubscription(t *testing.T) {
n := neko.Start(t)
n.It("matches an explicit path", func() {
sub := ParseSubscription("foo")
assert.True(t, sub.Match("foo"))
assert.False(t, sub.Match("bar"))
assert.False(t, sub.Match("foo2"))
})
n.It("uses + to match any segment", func() {
sub := ParseSubscription("+")
assert.True(t, sub.Match("foo"))
assert.False(t, sub.Match("foo/bar"))
})
n.It("uses + to match a segment after literal", func() {
sub := ParseSubscription("foo/+")
assert.True(t, sub.Match("foo/bar"))
assert.False(t, sub.Match("foo"))
assert.False(t, sub.Match("bar/foo"))
assert.False(t, sub.Match("bar/foo/baz"))
})
n.It("uses # to match any tail", func() {
sub := ParseSubscription("foo/#")
assert.True(t, sub.Match("foo/bar"))
assert.True(t, sub.Match("foo/bar/baz"))
assert.True(t, sub.Match("foo/bar/baz/quz"))
assert.False(t, sub.Match("foo"))
assert.False(t, sub.Match("bar"))
assert.False(t, sub.Match("bar/foo"))
assert.False(t, sub.Match("bar/qux"))
})
n.Meow()
}