Add language to inventaire search book
This commit is contained in:
@@ -27,12 +27,15 @@ func computeInventaireApiUrl(paths ...string) (*url.URL, error) {
|
||||
return callapiutils.ComputeUrl(baseUrl, paths...)
|
||||
}
|
||||
|
||||
func CallInventaireSearch(searchterm string, limit int, offset int) (InventaireSearchResult, error) {
|
||||
func CallInventaireSearch(searchterm string, lang string, limit int, offset int) (InventaireSearchResult, error) {
|
||||
var queryResult InventaireSearchResult
|
||||
u, err := computeInventaireApiUrl("search")
|
||||
if err != nil {
|
||||
return queryResult, err
|
||||
}
|
||||
if lang != "" {
|
||||
callapiutils.AddQueryParam(u, "lang", lang)
|
||||
}
|
||||
if limit != 0 {
|
||||
callapiutils.AddQueryParamInt(u, "limit", limit)
|
||||
}
|
||||
|
||||
@@ -6,8 +6,17 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCallInventaireSearch_NoParameters(t *testing.T) {
|
||||
result, err := CallInventaireSearch("salammbo", "", 0, 0)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.Equal(t, 17, result.Total)
|
||||
assert.Equal(t, 10, len(result.Results))
|
||||
}
|
||||
|
||||
func TestCallInventaireSearch_NoLimit(t *testing.T) {
|
||||
result, err := CallInventaireSearch("salammbo", 0, 0)
|
||||
result, err := CallInventaireSearch("salammbo", "fr", 0, 0)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -16,7 +25,7 @@ func TestCallInventaireSearch_NoLimit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCallInventaireSearch_Limit(t *testing.T) {
|
||||
result, err := CallInventaireSearch("salammbo", 5, 0)
|
||||
result, err := CallInventaireSearch("salammbo", "fr", 5, 0)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -25,7 +34,7 @@ func TestCallInventaireSearch_Limit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCallInventaireSearch_Offset(t *testing.T) {
|
||||
result, err := CallInventaireSearch("salammbo", 0, 15)
|
||||
result, err := CallInventaireSearch("salammbo", "fr", 0, 15)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user