From 4958ddc411f94a617455beb821a86da10566aad4 Mon Sep 17 00:00:00 2001 From: filipecosta90 Date: Sun, 9 Aug 2020 16:40:34 +0100 Subject: [PATCH] [add] improved testing by indexing check --- redisearch/redisearch_test.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/redisearch/redisearch_test.go b/redisearch/redisearch_test.go index 703d127..10dcc92 100644 --- a/redisearch/redisearch_test.go +++ b/redisearch/redisearch_test.go @@ -383,23 +383,35 @@ func TestDelete(t *testing.T) { err = c.IndexOptions(DefaultIndexingOptions, doc) assert.Nil(t, err) - // now we should have 1 document (id = doc1) + // Wait for all documents to be indexed info, err = c.Info() assert.Nil(t, err) - if !info.IsIndexing { - assert.Equal(t, uint64(1), info.DocCount) + for info.IsIndexing { + time.Sleep(time.Second) + info, err = c.Info() + assert.Nil(t, err) } + // now we should have 1 document (id = doc1) + info, err = c.Info() + assert.Nil(t, err) + assert.Equal(t, uint64(1), info.DocCount) + // delete the document from the index err = c.Delete("TestDelete-doc1", true) assert.Nil(t, err) - // validate that the index is empty again + // Wait for all documents to be indexed info, err = c.Info() assert.Nil(t, err) - if !info.IsIndexing { - assert.Equal(t, uint64(0), info.DocCount) + for info.IsIndexing { + time.Sleep(time.Second) + info, err = c.Info() + assert.Nil(t, err) } + + assert.Nil(t, err) + assert.Equal(t, uint64(0), info.DocCount) teardown(c) }