Switch from open library API to Inventaire API
This commit is contained in:
46
internal/inventaire/inventaire_test.go
Normal file
46
internal/inventaire/inventaire_test.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package inventaire
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCallInventaireSearch_NoLimit(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_Limit(t *testing.T) {
|
||||
result, err := CallInventaireSearch("salammbo", 5, 0)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.Equal(t, 17, result.Total)
|
||||
assert.Equal(t, 5, len(result.Results))
|
||||
}
|
||||
|
||||
func TestCallInventaireSearch_Offset(t *testing.T) {
|
||||
result, err := CallInventaireSearch("salammbo", 0, 15)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
assert.Equal(t, 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 (1894–1963)", result.Author.Description)
|
||||
}
|
||||
Reference in New Issue
Block a user