33 lines
986 B
Go
33 lines
986 B
Go
package apitest
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.artlef.fr/PersonalLibraryManager/internal/dto"
|
|
"git.artlef.fr/PersonalLibraryManager/internal/testutils"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetWantReadBooksHandler_Demo(t *testing.T) {
|
|
router := testutils.TestSetup()
|
|
|
|
token := testutils.ConnectDemoUser(router)
|
|
result := testGetWantReadBooksHandler(t, router, token, 200)
|
|
assert.Equal(t, 2, len(result.Books))
|
|
assert.Equal(t, int64(2), result.Count)
|
|
}
|
|
|
|
func TestGetWantReadBooksHandler_Demo2(t *testing.T) {
|
|
router := testutils.TestSetup()
|
|
|
|
token := testutils.ConnectDemo2User(router)
|
|
result := testGetWantReadBooksHandler(t, router, token, 200)
|
|
assert.Equal(t, 0, len(result.Books))
|
|
assert.Equal(t, int64(0), result.Count)
|
|
}
|
|
|
|
func testGetWantReadBooksHandler(t *testing.T, router *gin.Engine, userToken string, expectedCode int) dto.BookUserGet {
|
|
return testGetbooksHandler(t, router, userToken, expectedCode, "/ws/mybooks/wantread")
|
|
}
|