From 0cb58facef66da4b15d830bb18af5f6e9159c05a Mon Sep 17 00:00:00 2001 From: Sahil Goel Date: Tue, 29 Aug 2017 00:04:47 +0530 Subject: [PATCH] tests: Fix flake in TestSetExpiring * Fix Test Case 3 of #187 --- set/set_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/set/set_test.go b/set/set_test.go index f75192d..4545f02 100644 --- a/set/set_test.go +++ b/set/set_test.go @@ -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 +}