Skip to content

Commit

Permalink
Adds test for SearchDsl source filtering
Browse files Browse the repository at this point in the history
Signed-off-by: Corentin Kerisit <[email protected]>
  • Loading branch information
cerisier committed Mar 17, 2016
1 parent ef69a23 commit 60810b1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/searchsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,21 @@ func TestSearch(t *testing.T) {
h1 := gou.NewJsonHelper(b)
So(h1.String("name"), ShouldEqual, "Wayne Gretzky")
})

Convey("Search query with filtered source fields", t, func() {

qry := Search("oilers").SourceFields("name", "goals").Pretty().Query(
Query().All(),
)
out, err := qry.Result(c)

So(err, ShouldBeNil)
So(out, ShouldNotBeNil)
So(out.Hits.Len(), ShouldEqual, 10)
So(out.Hits.Total, ShouldEqual, 14)

b, err := out.Hits.Hits[0].Source.MarshalJSON()
h1 := gou.NewJsonHelper(b)
So(h1.Keys(), ShouldResemble, []string{"name", "goals"})
})
}

0 comments on commit 60810b1

Please sign in to comment.