Add open library API call when search has no result

This commit is contained in:
2025-12-27 01:23:40 +01:00
parent 746f6312b1
commit 167e711649
7 changed files with 1261 additions and 20 deletions

View File

@@ -0,0 +1,27 @@
package openlibrary_test
import (
"testing"
"git.artlef.fr/PersonalLibraryManager/internal/openlibrary"
"github.com/stretchr/testify/assert"
)
func TestCallOpenLibrary(t *testing.T) {
result, err := openlibrary.CallOpenLibrary("man in high castle", 0, 0)
assert.Nil(t, err)
assert.Equal(t, result.NumFound, 25)
assert.Equal(t, len(result.Books), 25)
}
func TestCallOpenLibraryLimit(t *testing.T) {
result, err := openlibrary.CallOpenLibrary("man in high castle", 10, 0)
assert.Nil(t, err)
assert.Equal(t, len(result.Books), 10)
}
func TestCallOpenLibraryOffset(t *testing.T) {
result, err := openlibrary.CallOpenLibrary("man in high castle", 0, 10)
assert.Nil(t, err)
assert.Equal(t, len(result.Books), 15)
}