From 4c9459a02b2004b093e52bd402769010f5082340 Mon Sep 17 00:00:00 2001 From: Marin Bek Date: Mon, 17 Nov 2014 07:25:48 +0100 Subject: [PATCH] Use slices instead of variadic function --- goes.go | 6 +++--- goes_test.go | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/goes.go b/goes.go index 9216818..5629c0c 100644 --- a/goes.go +++ b/goes.go @@ -430,7 +430,7 @@ func (b Bucket) Aggregation(name string) Aggregation { } // PutMapping registers a specific mapping for one or more types in one or more indexes -func (c *Connection) PutMapping(typeName string, mapping map[string]interface{}, indexes ...string) (Response, error) { +func (c *Connection) PutMapping(typeName string, mapping map[string]interface{}, indexes []string) (Response, error) { r := Request{ Conn: c, @@ -443,7 +443,7 @@ func (c *Connection) PutMapping(typeName string, mapping map[string]interface{}, return r.Run() } -func (c *Connection) GetMapping(types []string, indexes ...string) (Response, error) { +func (c *Connection) GetMapping(types []string, indexes []string) (Response, error) { r := Request{ Conn: c, @@ -456,7 +456,7 @@ func (c *Connection) GetMapping(types []string, indexes ...string) (Response, er } // IndicesExist checks whether index (or indices) exist on the server -func (c *Connection) IndicesExist(indexes ...string) (bool, error) { +func (c *Connection) IndicesExist(indexes []string) (bool, error) { r := Request{ Conn: c, diff --git a/goes_test.go b/goes_test.go index a0026e3..ec3f492 100644 --- a/goes_test.go +++ b/goes_test.go @@ -1015,7 +1015,7 @@ func (s *GoesTestSuite) TestPutMapping(c *C) { }, }, } - response, err = conn.PutMapping("tweet", mapping, indexName) + response, err = conn.PutMapping("tweet", mapping, []string{indexName}) c.Assert(err, IsNil) c.Assert(response.Acknowledged, Equals, true) @@ -1023,24 +1023,25 @@ func (s *GoesTestSuite) TestPutMapping(c *C) { } func (s *GoesTestSuite) TestIndicesExist(c *C) { - indexName := "testindicesexist" + indices := []string{"testindicesexist"} conn := NewConnection(ES_HOST, ES_PORT) // just in case - conn.DeleteIndex(indexName) + conn.DeleteIndex(indices[0]) - exists, err := conn.IndicesExist(indexName) + exists, err := conn.IndicesExist(indices) c.Assert(exists, Equals, false) - _, err = conn.CreateIndex(indexName, map[string]interface{}{}) + _, err = conn.CreateIndex(indices[0], map[string]interface{}{}) c.Assert(err, IsNil) - defer conn.DeleteIndex(indexName) + defer conn.DeleteIndex(indices[0]) time.Sleep(200 * time.Millisecond) - exists, err = conn.IndicesExist(indexName) + exists, err = conn.IndicesExist(indices) c.Assert(exists, Equals, true) - exists, err = conn.IndicesExist(indexName, "nonexistent") + indices = append(indices, "nonexistent") + exists, err = conn.IndicesExist(indices) c.Assert(exists, Equals, false) } @@ -1138,7 +1139,7 @@ func (s *GoesTestSuite) TestGetMapping(c *C) { time.Sleep(300 * time.Millisecond) - response, err := conn.GetMapping([]string{docType}, indexName) + response, err := conn.GetMapping([]string{docType}, []string{indexName}) c.Assert(err, Equals, nil) c.Assert(len(response.Raw), Equals, 0) @@ -1155,7 +1156,7 @@ func (s *GoesTestSuite) TestGetMapping(c *C) { c.Assert(err, IsNil) time.Sleep(200 * time.Millisecond) - response, err = conn.GetMapping([]string{docType}, indexName) + response, err = conn.GetMapping([]string{docType}, []string{indexName}) c.Assert(err, Equals, nil) c.Assert(len(response.Raw), Not(Equals), 0) }