Make "want read" button work
This commit is contained in:
35
internal/apitest/put_userbook_wantread_test.go
Normal file
35
internal/apitest/put_userbook_wantread_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package apitest
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/testutils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPutWantRead_SetTrue(t *testing.T) {
|
||||
payload :=
|
||||
`{
|
||||
"wantread": true
|
||||
}`
|
||||
bookId := "17"
|
||||
testPutWantReadUserBooks(t, payload, bookId, http.StatusOK)
|
||||
book := testGetBook(t, bookId, http.StatusOK)
|
||||
assert.Equal(t, true, book.WantRead)
|
||||
}
|
||||
|
||||
func TestPutWantRead_SetFalse(t *testing.T) {
|
||||
payload :=
|
||||
`{
|
||||
"wantread": false
|
||||
}`
|
||||
bookId := "2"
|
||||
testPutWantReadUserBooks(t, payload, bookId, http.StatusOK)
|
||||
book := testGetBook(t, bookId, http.StatusOK)
|
||||
assert.Equal(t, false, book.WantRead)
|
||||
}
|
||||
|
||||
func testPutWantReadUserBooks(t *testing.T, payload string, bookId string, expectedCode int) {
|
||||
testutils.TestBookPutCallWithDemoPayload(t, payload, bookId, expectedCode, "/book/"+bookId+"/wantread")
|
||||
}
|
||||
Reference in New Issue
Block a user