Skip to content

Commit

Permalink
Add another test for TermQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
olivere committed Dec 17, 2021
1 parent da7a99e commit 3a2e4de
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions search_queries_term_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ func TestTermQuery(t *testing.T) {
}
}

func TestTermQueryWithCaseInsensitive(t *testing.T) {
q := NewTermQuery("user", "ki").CaseInsensitive(true)
src, err := q.Source()
if err != nil {
t.Fatal(err)
}
data, err := json.Marshal(src)
if err != nil {
t.Fatalf("marshaling to JSON failed: %v", err)
}
got := string(data)
expected := `{"term":{"user":{"case_insensitive":true,"value":"ki"}}}`
if got != expected {
t.Errorf("expected\n%s\n,got:\n%s", expected, got)
}
}

func TestTermQueryWithOptions(t *testing.T) {
q := NewTermQuery("user", "ki")
q = q.Boost(2.79)
Expand Down

0 comments on commit 3a2e4de

Please sign in to comment.