Returns a zero index for a lookup error case.

This commit is contained in:
James Phillips 2015-11-17 09:25:20 -08:00
parent 049da2cef2
commit 533e6fc89e
2 changed files with 10 additions and 3 deletions

View File

@ -200,7 +200,7 @@ func (s *StateStore) PreparedQueryLookup(queryIDOrName string) (uint64, *structs
// but we check it here to be explicit about it (we'd never want to
// return the results from the first query w/o a name).
if queryIDOrName == "" {
return idx, nil, ErrMissingQueryID
return 0, nil, ErrMissingQueryID
}
// Try first by ID if it looks like they gave us an ID. We check the

View File

@ -376,8 +376,15 @@ func TestStateStore_PreparedQueryLookup(t *testing.T) {
// Make sure an empty lookup is well-behaved if there are actual queries
// in the state store.
if _, _, err = s.PreparedQueryLookup(""); err != ErrMissingQueryID {
t.Fatalf("bad: %v", err)
idx, actual, err = s.PreparedQueryLookup("")
if err != ErrMissingQueryID {
t.Fatalf("bad: %v ", err)
}
if idx != 0 {
t.Fatalf("bad index: %d", idx)
}
if actual != nil {
t.Fatalf("bad: %v", actual)
}
}