tests: Fix flake in TestSetExpiring

* Fix Test Case 3 of #187
This commit is contained in:
Sahil Goel 2017-08-29 00:04:47 +05:30 committed by Andrey Petrov
parent 50001bf172
commit 0cb58facef

View File

@ -74,7 +74,7 @@ func TestSetExpiring(t *testing.T) {
t.Errorf("failed to get barbar: %s", err)
}
b := s.ListPrefix("b")
if len(b) != 2 || b[0].Key() != "bar" || b[1].Key() != "barbar" {
if len(b) != 2 || !anyItemPresentWithKey(b, "bar") || !anyItemPresentWithKey(b, "barbar") {
t.Errorf("b-prefix incorrect: %q", b)
}
@ -89,3 +89,13 @@ func TestSetExpiring(t *testing.T) {
t.Error("not len 0 after clear")
}
}
func anyItemPresentWithKey(items []Item, key string) bool {
for _, item := range items {
if item.Key() == key {
return true
}
}
return false
}