From 92d2eb17fa1d057286b80f2c21e8f23d3b575318 Mon Sep 17 00:00:00 2001 From: Marin Bek Date: Tue, 11 Nov 2014 15:37:50 +0100 Subject: [PATCH] Test IndicesExist --- goes_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/goes_test.go b/goes_test.go index e223b54..23d0b43 100644 --- a/goes_test.go +++ b/goes_test.go @@ -1012,3 +1012,24 @@ func (s *GoesTestSuite) TestPutMapping(c *C) { c.Assert(response.Acknowledged, Equals, true) c.Assert(response.TimedOut, Equals, false) } + +func (s *GoesTestSuite) TestIndicesExist(c *C) { + indexName := "testindicesexist" + + conn := NewConnection(ES_HOST, ES_PORT) + // just in case + conn.DeleteIndex(indexName) + + exists, err := conn.IndicesExist(indexName) + c.Assert(exists, Equals, false) + + _, err = conn.CreateIndex(indexName, map[string]interface{}{}) + c.Assert(err, IsNil) + defer conn.DeleteIndex(indexName) + + exists, err = conn.IndicesExist(indexName) + c.Assert(exists, Equals, true) + + exists, err = conn.IndicesExist(indexName, "nonexistent") + c.Assert(exists, Equals, false) +}