Skip to content

Commit

Permalink
opensearchapi: add test to to verify url path for search
Browse files Browse the repository at this point in the history
Signed-off-by: Jakob Hahn <[email protected]>
  • Loading branch information
Jakob3xD committed Apr 3, 2024
1 parent 8c7df58 commit b30f40d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions opensearchapi/api_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package opensearchapi_test

import (
"fmt"
"strings"
"testing"

Expand Down Expand Up @@ -64,4 +65,18 @@ func TestSearch(t *testing.T) {
assert.NotNil(t, res)
osapitest.VerifyInspect(t, res.Inspect())
})

t.Run("url path", func(t *testing.T) {
req := &opensearchapi.SearchReq{}
httpReq, err := req.GetRequest()
assert.Nil(t, err)
require.NotNil(t, httpReq)
assert.Equal(t, "/_search", httpReq.URL.Path)

req = &opensearchapi.SearchReq{Indices: []string{index}}
httpReq, err = req.GetRequest()
assert.Nil(t, err)
require.NotNil(t, httpReq)
assert.Equal(t, fmt.Sprintf("/%s/_search", index), httpReq.URL.Path)
})
}

0 comments on commit b30f40d

Please sign in to comment.