Skip to content

Commit

Permalink
FEAT: Add TestPrefixQuery_AllOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
sdqri committed Sep 9, 2024
1 parent e1e3ce0 commit 781a2db
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions queries/prefixquery/prefix_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,30 @@ func TestPrefixQuery_WithNoOptions(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, expectedBody, string(jsonBody))
}

func TestPrefixQuery_AllOptions(t *testing.T) {
expectedBody := `{
"prefix": {
"user.id": {
"value": "ki",
"rewrite": "top_terms_boost_N",
"case_insensitive": true
}
}
}`

prefixQueryResult := pq.PrefixQuery(
"user.id",
"ki",
pq.WithRewrite(pq.TopTermsBoostN),
pq.WithCaseInsensitive(true),
)

err := prefixQueryResult.Err
prefixQuery := prefixQueryResult.Ok
assert.Nil(t, err)
jsonBody, err := json.Marshal(prefixQuery)
assert.Nil(t, err)
assert.JSONEq(t, expectedBody, string(jsonBody))
}

0 comments on commit 781a2db

Please sign in to comment.