From 167e20d669754e219f4eefbb1b9231762b4fd415 Mon Sep 17 00:00:00 2001 From: Paul Bonser Date: Thu, 2 Feb 2017 19:20:07 -0600 Subject: [PATCH] Make sure we delete those test indexes, even on failure --- goes_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/goes_test.go b/goes_test.go index 48c504c..8a82d1a 100644 --- a/goes_test.go +++ b/goes_test.go @@ -163,6 +163,7 @@ func (s *GoesTestSuite) TestDeleteIndexExistingIndex(c *C) { indexName := "testdeleteindexexistingindex" _, err := conn.CreateIndex(indexName, map[string]interface{}{}) + defer conn.DeleteIndex(indexName) c.Assert(err, IsNil) @@ -181,8 +182,12 @@ func (s *GoesTestSuite) TestUpdateIndexSettings(c *C) { conn := NewClient(ESHost, ESPort) indexName := "testupdateindex" + // Just in case + conn.DeleteIndex(indexName) + _, err := conn.CreateIndex(indexName, map[string]interface{}{}) c.Assert(err, IsNil) + defer conn.DeleteIndex(indexName) _, err = conn.UpdateIndexSettings(indexName, map[string]interface{}{ "index": map[string]interface{}{ @@ -201,6 +206,7 @@ func (s *GoesTestSuite) TestRefreshIndex(c *C) { _, err := conn.CreateIndex(indexName, map[string]interface{}{}) c.Assert(err, IsNil) + defer conn.DeleteIndex(indexName) _, err = conn.RefreshIndex(indexName) c.Assert(err, IsNil) @@ -216,6 +222,7 @@ func (s *GoesTestSuite) TestOptimize(c *C) { conn.DeleteIndex(indexName) _, err := conn.CreateIndex(indexName, map[string]interface{}{}) c.Assert(err, IsNil) + defer conn.DeleteIndex(indexName) // we must wait for a bit otherwise ES crashes time.Sleep(1 * time.Second) @@ -262,6 +269,7 @@ func (s *GoesTestSuite) TestBulkSend(c *C) { conn.DeleteIndex(indexName) _, err := conn.CreateIndex(indexName, nil) c.Assert(err, IsNil) + defer conn.DeleteIndex(indexName) response, err := conn.BulkSend(tweets) i := Item{ @@ -352,6 +360,7 @@ func (s *GoesTestSuite) TestStats(c *C) { conn.DeleteIndex(indexName) _, err := conn.CreateIndex(indexName, map[string]interface{}{}) c.Assert(err, IsNil) + defer conn.DeleteIndex(indexName) // we must wait for a bit otherwise ES crashes time.Sleep(1 * time.Second)