Skip to content

Commit

Permalink
Merge pull request mattbaird#255 from shawnps/master
Browse files Browse the repository at this point in the history
gofmt -s -w
  • Loading branch information
vrecan committed Mar 15, 2016
2 parents 22a5241 + 64a3215 commit 666f920
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 30 deletions.
2 changes: 0 additions & 2 deletions lib/catnodeinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"strings"
)



// newCatNodeInfo returns an instance of CatNodeInfo populated with the
// the information in the cat output indexLine which contains the
// specified fields. An err is returned if a field is not known.
Expand Down
2 changes: 1 addition & 1 deletion lib/clusterupdatesettings.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (c *Conn) UpdateSettings(settingType string, key string, value int) (Cluste
return retval, fmt.Errorf("settingType must be one of transient or persistent, you passed %s", settingType)
}
var url string = "/_cluster/state"
m := map[string]map[string]int{settingType: map[string]int{key: value}}
m := map[string]map[string]int{settingType: {key: value}}
body, err := c.DoCommand("PUT", url, nil, m)
if err != nil {
return retval, err
Expand Down
2 changes: 1 addition & 1 deletion lib/coretest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func NewTestConn() *Conn {
func waitFor(check func() bool, timeoutSecs int) {
timer := time.NewTicker(100 * time.Millisecond)
tryct := 0
for _ = range timer.C {
for range timer.C {
if check() {
timer.Stop()
break
Expand Down
2 changes: 1 addition & 1 deletion lib/indicesdeletemapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ func (c *Conn) DeleteMapping(index string, typeName string) (BaseResponse, error
}

return retval, err
}
}
8 changes: 4 additions & 4 deletions lib/indicesdeletemapping_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package elastigo

import (
"testing"
"net/http/httptest"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"
)

func TestDeleteMapping(t *testing.T) {
Expand All @@ -32,7 +32,7 @@ func TestDeleteMapping(t *testing.T) {
c.Domain = strings.Split(serverURL.Host, ":")[0]
c.Port = strings.Split(serverURL.Host, ":")[1]

_, err := c.DeleteMapping("this","exists")
_, err := c.DeleteMapping("this", "exists")
if err != nil {
t.Errorf("Expected no error and got, %s", err)
}
Expand All @@ -51,4 +51,4 @@ func TestDeleteMapping(t *testing.T) {
if err == nil {
t.Errorf("Expected error for no mapping and got none")
}
}
}
1 change: 0 additions & 1 deletion lib/searchfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ func (f *FilterWrap) MarshalJSON() ([]byte, error) {
*/


// Filter creates a blank FilterOp that can be customized with further function calls
// This is the starting point for constructing any filter query
// Examples:
Expand Down
32 changes: 16 additions & 16 deletions lib/searchfilter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
package elastigo

import (
. "github.com/smartystreets/goconvey/convey"
"testing"

. "github.com/smartystreets/goconvey/convey"
)

func TestFilterDsl(t *testing.T) {
Convey("And filter", t, func() {
filter := Filter().And(Filter().Term("test", "asdf")).
And(Filter().Range("rangefield", 1, 2, 3, 4, "+08:00"))
And(Filter().Range("rangefield", 1, 2, 3, 4, "+08:00"))
actual, err := GetJson(filter)

actualFilters := actual["and"].([]interface{})
Expand All @@ -46,8 +47,8 @@ func TestFilterDsl(t *testing.T) {

Convey("Not filter", t, func() {
filter := Filter().Not(Filter().Term("test", "asdf")).
Not(Filter().Range("rangefield", 1, 2, 3, 4, "+08:00"))
actual, err := GetJson(filter)
Not(Filter().Range("rangefield", 1, 2, 3, 4, "+08:00"))
actual, err := GetJson(filter)

actualFilters := actual["not"].([]interface{})

Expand All @@ -60,7 +61,7 @@ func TestFilterDsl(t *testing.T) {

Convey("Terms filter", t, func() {
filter := Filter().Terms("Sample", TEMAnd, "asdf", 123, true)
actual, err := GetJson(filter)
actual, err := GetJson(filter)

actualTerms := actual["terms"].(map[string]interface{})
actualValues := actualTerms["Sample"].([]interface{})
Expand All @@ -76,7 +77,7 @@ func TestFilterDsl(t *testing.T) {

Convey("Term filter", t, func() {
filter := Filter().Term("Sample", "asdf").Term("field2", 341.4)
actual, err := GetJson(filter)
actual, err := GetJson(filter)

actualTerm := actual["term"].(map[string]interface{})

Expand All @@ -88,7 +89,7 @@ func TestFilterDsl(t *testing.T) {

Convey("Range filter", t, func() {
filter := Filter().Range("rangefield", 1, 2, 3, 4, "+08:00")
actual, err := GetJson(filter)
actual, err := GetJson(filter)
//A bit lazy, probably should assert keys exist
actualRange := actual["range"].(map[string]interface{})["rangefield"].(map[string]interface{})

Expand All @@ -103,7 +104,7 @@ func TestFilterDsl(t *testing.T) {

Convey("Exists filter", t, func() {
filter := Filter().Exists("field1")
actual, err := GetJson(filter)
actual, err := GetJson(filter)

actualValue := actual["exists"].(map[string]interface{})

Expand All @@ -114,7 +115,7 @@ func TestFilterDsl(t *testing.T) {

Convey("Missing filter", t, func() {
filter := Filter().Missing("field1")
actual, err := GetJson(filter)
actual, err := GetJson(filter)

actualValue := actual["missing"].(map[string]interface{})

Expand All @@ -125,7 +126,7 @@ func TestFilterDsl(t *testing.T) {

Convey("Limit filter", t, func() {
filter := Filter().Limit(100)
actual, err := GetJson(filter)
actual, err := GetJson(filter)

actualValue := actual["limit"].(map[string]interface{})
So(err, ShouldBeNil)
Expand All @@ -135,7 +136,7 @@ func TestFilterDsl(t *testing.T) {

Convey("Type filter", t, func() {
filter := Filter().Type("my_type")
actual, err := GetJson(filter)
actual, err := GetJson(filter)

actualValue := actual["type"].(map[string]interface{})
So(err, ShouldBeNil)
Expand All @@ -145,7 +146,7 @@ func TestFilterDsl(t *testing.T) {

Convey("Ids filter", t, func() {
filter := Filter().Ids("test", "asdf", "fdsa")
actual, err := GetJson(filter)
actual, err := GetJson(filter)

actualValue := actual["ids"].(map[string]interface{})
actualValues := actualValue["values"].([]interface{})
Expand All @@ -160,7 +161,7 @@ func TestFilterDsl(t *testing.T) {

Convey("IdsByTypes filter", t, func() {
filter := Filter().IdsByTypes([]string{"my_type"}, "test", "asdf", "fdsa")
actual, err := GetJson(filter)
actual, err := GetJson(filter)

actualValue := actual["ids"].(map[string]interface{})
actualTypes := actualValue["type"].([]interface{})
Expand All @@ -177,7 +178,7 @@ func TestFilterDsl(t *testing.T) {

Convey("GeoDistance filter", t, func() {
filter := Filter().GeoDistance("100km", NewGeoField("pin.location", 32.3, 23.4))
actual, err := GetJson(filter)
actual, err := GetJson(filter)

actualValue := actual["geo_distance"].(map[string]interface{})
actualLocation := actualValue["pin.location"].(map[string]interface{})
Expand All @@ -189,7 +190,7 @@ func TestFilterDsl(t *testing.T) {

Convey("GeoDistanceRange filter", t, func() {
filter := Filter().GeoDistanceRange("100km", "200km", NewGeoField("pin.location", 32.3, 23.4))
actual, err := GetJson(filter)
actual, err := GetJson(filter)

actualValue := actual["geo_distance_range"].(map[string]interface{})
actualLocation := actualValue["pin.location"].(map[string]interface{})
Expand Down Expand Up @@ -256,7 +257,6 @@ func TestFilters(t *testing.T) {
So(out.Hits.Total, ShouldEqual, 2)
})


Convey("Filterng filter results", t, func() {
qry := Search("oilers").Filter(
Filter().Terms("pos", TEMDefault, "LW"),
Expand Down
2 changes: 0 additions & 2 deletions lib/searchsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func TestSearch(t *testing.T) {
So(out.Hits.Total, ShouldEqual, 3)
})


// A faceted search for what "type" of events there are
// - since we are not specifying an elasticsearch type it searches all ()
//
Expand Down Expand Up @@ -132,7 +131,6 @@ func TestSearch(t *testing.T) {
So(len(h.List("teams.terms")), ShouldEqual, 4)
})


Convey("Facet search with wildcard", t, func() {

qry := Search("oilers").Pretty().Facet(
Expand Down
4 changes: 2 additions & 2 deletions lib/shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
package elastigo

import (
"encoding/json"
"flag"
"log"
"encoding/json"
)

var (
Expand All @@ -40,4 +40,4 @@ func HasKey(input map[string]interface{}, key string) bool {
}

return false
}
}

0 comments on commit 666f920

Please sign in to comment.