Skip to content

Commit

Permalink
Converted test case to use mock test data
Browse files Browse the repository at this point in the history
  • Loading branch information
lr-paul committed Aug 27, 2015
1 parent 080a19c commit 92bbdaa
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions lib/searchfacet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,33 @@
package elastigo

import (
//"encoding/json"
"fmt"
"github.com/araddon/gou"
"github.com/bmizerany/assert"
. "github.com/smartystreets/goconvey/convey"
"testing"
)

func TestFacetRegex(t *testing.T) {

c := NewTestConn()
PopulateTestDB(t, c)
defer func() {
TearDownTestDB(c)
}()

Convey("Wildcard request query", t, func() {

// This is a possible solution for auto-complete
out, err := Search("oilers").Size("0").Facet(
Facet().Regex("name", "[jk].*").Size("8"),
).Result(c)
So(err, ShouldBeNil)
So(out, ShouldNotBeNil)

// This is a possible solution for auto-complete
out, _ := Search("github").Size("0").Facet(
Facet().Regex("repository.name", "no.*").Size("8"),
).Result(c)
if out == nil || &out.Hits == nil {
t.Fail()
return
}
//Debug(string(out.Facets))
fh := gou.NewJsonHelper([]byte(out.Facets))
facets := fh.Helpers("/repository.name/terms")
assert.T(t, len(facets) == 8, fmt.Sprintf("Should have 8? but was %v", len(facets)))
// for _, f := range facets {
// Debug(f)
// }
// Debug(string(out.Facets))
fh := gou.NewJsonHelper([]byte(out.Facets))
facets := fh.Helpers("/name/terms")
So(err, ShouldBeNil)
So(facets, ShouldNotBeNil)
So(len(facets), ShouldEqual, 4)
})
}

0 comments on commit 92bbdaa

Please sign in to comment.