From 1a978a45918ff2ee476352cdd8780f6a757a3e76 Mon Sep 17 00:00:00 2001 From: Marty Schoch Date: Mon, 26 Oct 2015 16:41:58 -0400 Subject: [PATCH] fix go vet issues and cleanup reader/iterator --- index/store/test/iterator.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/index/store/test/iterator.go b/index/store/test/iterator.go index be147edd..37542e50 100644 --- a/index/store/test/iterator.go +++ b/index/store/test/iterator.go @@ -151,9 +151,21 @@ func CommonTestPrefixIteratorSeek(t *testing.T, s store.KVStore) { if err != nil { t.Fatal(err) } + defer func() { + err := reader.Close() + if err != nil { + t.Fatal(err) + } + }() // get an iterator on a central subset of the data iter := reader.PrefixIterator([]byte("b")) + defer func() { + err := iter.Close() + if err != nil { + t.Fatal(err) + } + }() // check that all keys have prefix found := []string{} @@ -162,7 +174,7 @@ func CommonTestPrefixIteratorSeek(t *testing.T, s store.KVStore) { } for _, f := range found { if !strings.HasPrefix(f, "b") { - t.Errorf("got key '%s' that doesn't have correct prefix") + t.Errorf("got key '%s' that doesn't have correct prefix", f) } } if len(found) != 3 { @@ -176,7 +188,7 @@ func CommonTestPrefixIteratorSeek(t *testing.T, s store.KVStore) { } for _, f := range found { if !strings.HasPrefix(f, "b") { - t.Errorf("got key '%s' that doesn't have correct prefix") + t.Errorf("got key '%s' that doesn't have correct prefix", f) } } if len(found) != 3 { @@ -190,7 +202,7 @@ func CommonTestPrefixIteratorSeek(t *testing.T, s store.KVStore) { } for _, f := range found { if !strings.HasPrefix(f, "b") { - t.Errorf("got key '%s' that doesn't have correct prefix") + t.Errorf("got key '%s' that doesn't have correct prefix", f) } } if len(found) != 0 {