Collection: new widget to add book to collection
This commit is contained in:
@@ -3,6 +3,7 @@ package apitest
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -15,14 +16,14 @@ import (
|
||||
)
|
||||
|
||||
func TestSearchBook_MultipleBooks(t *testing.T) {
|
||||
result := testSearchBook(t, "san", "", "")
|
||||
result := testSearchBook(t, "san", "", "", dto.NoInventaireSearch)
|
||||
|
||||
assert.Equal(t, int64(2), result.Count)
|
||||
assert.Equal(t, 2, len(result.Books))
|
||||
}
|
||||
|
||||
func TestSearchBook_OneBookNotUserBook(t *testing.T) {
|
||||
result := testSearchBook(t, "iliade", "", "")
|
||||
result := testSearchBook(t, "iliade", "", "", dto.NoInventaireSearch)
|
||||
assert.Equal(t, int64(1), result.Count)
|
||||
assert.Equal(t,
|
||||
[]dto.BookItemGet{{
|
||||
@@ -38,7 +39,7 @@ func TestSearchBook_OneBookNotUserBook(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSearchBook_OneBookRead(t *testing.T) {
|
||||
result := testSearchBook(t, "dieux", "", "")
|
||||
result := testSearchBook(t, "dieux", "", "", dto.NoInventaireSearch)
|
||||
assert.Equal(t, int64(1), result.Count)
|
||||
assert.Equal(t,
|
||||
[]dto.BookItemGet{{
|
||||
@@ -55,7 +56,7 @@ func TestSearchBook_OneBookRead(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSearchBook_OneBookStartRead(t *testing.T) {
|
||||
result := testSearchBook(t, "Recherches", "", "")
|
||||
result := testSearchBook(t, "Recherches", "", "", dto.NoInventaireSearch)
|
||||
assert.Equal(t, int64(1), result.Count)
|
||||
assert.Equal(t,
|
||||
[]dto.BookItemGet{{
|
||||
@@ -72,7 +73,7 @@ func TestSearchBook_OneBookStartRead(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSearchBook_ISBN(t *testing.T) {
|
||||
result := testSearchBook(t, "9782070337903", "", "")
|
||||
result := testSearchBook(t, "9782070337903", "", "", dto.NoInventaireSearch)
|
||||
assert.Equal(t, int64(1), result.Count)
|
||||
assert.Equal(t,
|
||||
[]dto.BookItemGet{{
|
||||
@@ -88,7 +89,7 @@ func TestSearchBook_ISBN(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSearchBook_ISBNInventaire(t *testing.T) {
|
||||
result := testSearchBook(t, "9782253158400", "", "")
|
||||
result := testSearchBook(t, "9782253158400", "", "", dto.InventaireIfNothingFound)
|
||||
assert.Equal(t, int64(1), result.Count)
|
||||
assert.Equal(t,
|
||||
[]dto.BookItemGet{{
|
||||
@@ -107,17 +108,17 @@ func TestSearchBook_ISBNInventaire(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSearchBook_Limit(t *testing.T) {
|
||||
result := testSearchBook(t, "a", "10", "")
|
||||
result := testSearchBook(t, "a", "10", "", dto.NoInventaireSearch)
|
||||
assert.Equal(t, 10, len(result.Books))
|
||||
}
|
||||
|
||||
func TestSearchBook_Offset(t *testing.T) {
|
||||
result := testSearchBook(t, "sa", "", "2")
|
||||
result := testSearchBook(t, "sa", "", "2", dto.NoInventaireSearch)
|
||||
assert.Equal(t, int64(5), result.Count)
|
||||
assert.Equal(t, 3, len(result.Books))
|
||||
}
|
||||
|
||||
func testSearchBook(t *testing.T, searchterm string, limit string, offset string) dto.BookItemsGet {
|
||||
func testSearchBook(t *testing.T, searchterm string, limit string, offset string, inventaireSearchType dto.InventaireSearchType) dto.BookItemsGet {
|
||||
router := testutils.TestSetup()
|
||||
|
||||
u, err := url.Parse("/ws/search/" + searchterm)
|
||||
@@ -137,6 +138,7 @@ func testSearchBook(t *testing.T, searchterm string, limit string, offset string
|
||||
|
||||
q := u.Query()
|
||||
q.Set("lang", "fr")
|
||||
q.Set("inventaire", strconv.Itoa(int(inventaireSearchType)))
|
||||
u.RawQuery = q.Encode()
|
||||
|
||||
token := testutils.ConnectDemoUser(router)
|
||||
|
||||
Reference in New Issue
Block a user