mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
test (isHidden) add unit test for isHidden function
This commit is contained in:
parent
5851cb5b8d
commit
1b5f9eb013
@ -789,7 +789,6 @@ func TestStoreWatchRecursiveCreateDeeperThanHiddenKey(t *testing.T) {
|
||||
s.Create("/_foo/bar/baz", false, "baz", false, Permanent)
|
||||
|
||||
e := nbselect(w.EventChan)
|
||||
// The NotNil assertion currently fails
|
||||
assert.NotNil(t, e, "")
|
||||
assert.Equal(t, e.Action, "create", "")
|
||||
assert.Equal(t, e.Node.Key, "/_foo/bar/baz", "")
|
||||
|
43
store/watcher_hub_test.go
Normal file
43
store/watcher_hub_test.go
Normal file
@ -0,0 +1,43 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestIsHidden tests isHidden functions.
|
||||
func TestIsHidden(t *testing.T) {
|
||||
// watch at "/"
|
||||
// key is "/_foo", hidden to "/"
|
||||
// expected: hidden = true
|
||||
watch := "/"
|
||||
key := "/_foo"
|
||||
hidden := isHidden(watch, key)
|
||||
if !hidden {
|
||||
t.Fatalf("%v should be hidden to %v\n", key, watch)
|
||||
}
|
||||
|
||||
// watch at "/_foo"
|
||||
// key is "/_foo", not hidden to "/_foo"
|
||||
// expected: hidden = false
|
||||
watch = "/_foo"
|
||||
hidden = isHidden(watch, key)
|
||||
if hidden {
|
||||
t.Fatalf("%v should not be hidden to %v\n", key, watch)
|
||||
}
|
||||
|
||||
// watch at "/_foo/"
|
||||
// key is "/_foo/foo", not hidden to "/_foo"
|
||||
key = "/_foo/foo"
|
||||
hidden = isHidden(watch, key)
|
||||
if hidden {
|
||||
t.Fatalf("%v should not be hidden to %v\n", key, watch)
|
||||
}
|
||||
|
||||
// watch at "/_foo/"
|
||||
// key is "/_foo/_foo", hidden to "/_foo"
|
||||
key = "/_foo/_foo"
|
||||
hidden = isHidden(watch, key)
|
||||
if !hidden {
|
||||
t.Fatalf("%v should be hidden to %v\n", key, watch)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user