Files
bibliomane/internal/inventaire/inventaire_test.go

56 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package inventaire
import (
"testing"
"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, int64(17), result.Total)
assert.Equal(t, 10, len(result.Results))
}
func TestCallInventaireSearch_NoLimit(t *testing.T) {
result, err := CallInventaireSearch("salammbo", "fr", 0, 0)
if err != nil {
t.Error(err)
}
assert.Equal(t, int64(17), result.Total)
assert.Equal(t, 10, len(result.Results))
}
func TestCallInventaireSearch_Limit(t *testing.T) {
result, err := CallInventaireSearch("salammbo", "fr", 5, 0)
if err != nil {
t.Error(err)
}
assert.Equal(t, int64(17), result.Total)
assert.Equal(t, 5, len(result.Results))
}
func TestCallInventaireSearch_Offset(t *testing.T) {
result, err := CallInventaireSearch("salammbo", "fr", 0, 15)
if err != nil {
t.Error(err)
}
assert.Equal(t, int64(17), result.Total)
assert.Equal(t, 2, len(result.Results))
}
func TestCallInventaireBook_BraveNewWorld(t *testing.T) {
result, err := CallInventaireBook("Q191949", "fr")
if err != nil {
t.Error(err)
}
assert.Equal(t, "Le Meilleur des mondes", result.Title)
assert.Equal(t, "roman de Aldous Huxley", result.Description)
assert.Equal(t, "Q81447", result.Author.ID)
assert.Equal(t, "Aldous Huxley", result.Author.Name)
assert.Equal(t, "écrivain, romancier et philosophe britannique (18941963)", result.Author.Description)
}