mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Added test for cache changes
This commit is contained in:
@@ -3,6 +3,7 @@ package gnatsd
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -190,6 +191,23 @@ func TestCacheBehavior(t *testing.T) {
|
|||||||
verifyMember(r, a, t)
|
verifyMember(r, a, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkBool(b, expected bool, t *testing.T) {
|
||||||
|
if b != expected {
|
||||||
|
debug.PrintStack()
|
||||||
|
t.Fatalf("Expected %v, but got %v\n", expected, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMatchLiterals(t *testing.T) {
|
||||||
|
checkBool(matchLiteral([]byte("foo"), []byte("foo")), true, t)
|
||||||
|
checkBool(matchLiteral([]byte("foo"), []byte("bar")), false, t)
|
||||||
|
checkBool(matchLiteral([]byte("foo"), []byte("*")), true, t)
|
||||||
|
checkBool(matchLiteral([]byte("foo"), []byte(">")), true, t)
|
||||||
|
checkBool(matchLiteral([]byte("foo.bar"), []byte(">")), true, t)
|
||||||
|
checkBool(matchLiteral([]byte("foo.bar"), []byte("foo.>")), true, t)
|
||||||
|
checkBool(matchLiteral([]byte("foo.bar"), []byte("bar.>")), false, t)
|
||||||
|
}
|
||||||
|
|
||||||
var subs [][]byte
|
var subs [][]byte
|
||||||
var toks = []string{"apcera", "continuum", "component", "router", "api", "imgr", "jmgr", "auth"}
|
var toks = []string{"apcera", "continuum", "component", "router", "api", "imgr", "jmgr", "auth"}
|
||||||
var sl = New()
|
var sl = New()
|
||||||
@@ -214,7 +232,7 @@ func subsInit(pre string) {
|
|||||||
sub = t
|
sub = t
|
||||||
}
|
}
|
||||||
subs = append(subs, []byte(sub))
|
subs = append(subs, []byte(sub))
|
||||||
if (len(strings.Split(sub, ".")) < 5) {
|
if len(strings.Split(sub, ".")) < 5 {
|
||||||
subsInit(sub)
|
subsInit(sub)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user