add dispatcher

simplify transport implementation
support wildcard subscriptions
This commit is contained in:
Marcelo Pires
2018-09-24 16:13:57 +02:00
parent 8583e29645
commit 33a61d6d27
13 changed files with 786 additions and 410 deletions
+16 -6
View File
@@ -1,20 +1,23 @@
package subscription
import "testing"
import (
"testing"
)
/*
assertEqual( ["/**", "/foo", "/*"],
Channel.expand("/foo") )
channel.expand("/foo") )
assertEqual( ["/**", "/foo/bar", "/foo/*", "/foo/**"],
Channel.expand("/foo/bar") )
channel.expand("/foo/bar") )
assertEqual( ["/**", "/foo/bar/qux", "/foo/bar/*", "/foo/**", "/foo/bar/**"],
*/
func TestIsValidChannel(t *testing.T) {
func TestIsValidSubscriptionName(t *testing.T) {
type args struct {
channel string
}
tests := []struct {
name string
args args
@@ -62,11 +65,18 @@ func TestIsValidChannel(t *testing.T) {
},
want: false,
},
{
name: "asterisk before slash",
args: args{
channel: "/foo*",
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IsValidChannel(tt.args.channel); got != tt.want {
t.Errorf("IsValidChannel() = %v, want %v", got, tt.want)
if got := IsValidSubscriptionName(tt.args.channel); got != tt.want {
t.Errorf("isValidChannelName() = %v, want %v", got, tt.want)
}
})
}