author is now on separate table
This commit is contained in:
@@ -11,11 +11,20 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPostBookHandler_Ok(t *testing.T) {
|
||||
func TestPostBookHandler_OkAuthorExist(t *testing.T) {
|
||||
bookJson :=
|
||||
`{
|
||||
"title": "Le château",
|
||||
"author": "Kafka"
|
||||
"title": "Le Procès",
|
||||
"author": "Franz Kafka"
|
||||
}`
|
||||
testPostBookHandler(t, bookJson, 200)
|
||||
}
|
||||
|
||||
func TestPostBookHandler_OkNewAuthor(t *testing.T) {
|
||||
bookJson :=
|
||||
`{
|
||||
"title": "Le joueur d'échecs",
|
||||
"author": "Stefan Zweig"
|
||||
}`
|
||||
testPostBookHandler(t, bookJson, 200)
|
||||
}
|
||||
@@ -23,7 +32,7 @@ func TestPostBookHandler_Ok(t *testing.T) {
|
||||
func TestPostBookHandler_OkOnlyTitle(t *testing.T) {
|
||||
bookJson :=
|
||||
`{
|
||||
"title": "Le château"
|
||||
"title": "Le Procès"
|
||||
}`
|
||||
testPostBookHandler(t, bookJson, 200)
|
||||
}
|
||||
|
||||
@@ -61,6 +61,22 @@ func TestSearchBook_OneBookRead(t *testing.T) {
|
||||
books)
|
||||
}
|
||||
|
||||
func TestSearchBook_ISBN(t *testing.T) {
|
||||
books := testSearchBook(t, "9782070337903", "", "")
|
||||
assert.Equal(t, 1, len(books))
|
||||
assert.Equal(t,
|
||||
[]bookSearchGet{{
|
||||
Title: "Le complot contre l'Amérique",
|
||||
Author: "Philip Roth",
|
||||
Id: 22,
|
||||
Rating: 6,
|
||||
Read: true,
|
||||
WantRead: false,
|
||||
CoverPath: "/bookcover/lecomplotcontrelamerique.jpg",
|
||||
}},
|
||||
books)
|
||||
}
|
||||
|
||||
func TestSearchBook_Limit(t *testing.T) {
|
||||
books := testSearchBook(t, "a", "10", "")
|
||||
assert.Equal(t, 10, len(books))
|
||||
|
||||
Reference in New Issue
Block a user