Adds a test to ensure we don't return a nil slice.
This commit is contained in:
parent
e0739eb95b
commit
a0211db3b9
|
@ -379,6 +379,18 @@ func TestStateStore_PreparedQueryLookup(t *testing.T) {
|
||||||
func TestStateStore_PreparedQueryList(t *testing.T) {
|
func TestStateStore_PreparedQueryList(t *testing.T) {
|
||||||
s := testStateStore(t)
|
s := testStateStore(t)
|
||||||
|
|
||||||
|
// Make sure an empty (non-nil) slice is returned if there are no queries.
|
||||||
|
idx, actual, err := s.PreparedQueryList()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
if idx != 0 {
|
||||||
|
t.Fatalf("bad index: %d", idx)
|
||||||
|
}
|
||||||
|
if actual == nil || len(actual) != 0 {
|
||||||
|
t.Fatalf("bad: %v", actual)
|
||||||
|
}
|
||||||
|
|
||||||
// Set up our test environment.
|
// Set up our test environment.
|
||||||
testRegisterNode(t, s, 1, "foo")
|
testRegisterNode(t, s, 1, "foo")
|
||||||
testRegisterService(t, s, 2, "foo", "redis")
|
testRegisterService(t, s, 2, "foo", "redis")
|
||||||
|
@ -439,7 +451,7 @@ func TestStateStore_PreparedQueryList(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
idx, actual, err := s.PreparedQueryList()
|
idx, actual, err = s.PreparedQueryList()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue