Browse Source

Use slices instead of variadic function

tags/v1.0.0
Marin Bek 9 years ago
parent
commit
4c9459a02b
2 changed files with 14 additions and 13 deletions
  1. +3
    -3
      goes.go
  2. +11
    -10
      goes_test.go

+ 3
- 3
goes.go View File

@@ -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,


+ 11
- 10
goes_test.go View File

@@ -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)
}

Loading…
Cancel
Save