Use dto from code for unit tests
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/dto"
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/testutils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -59,23 +60,24 @@ func TestGetReadBooksHandler_CheckOneBook(t *testing.T) {
|
||||
|
||||
token := testutils.ConnectDemo2User(router)
|
||||
result := testGetReadBooksHandler(t, router, token, 200, "100", "")
|
||||
var book bookUserGetBook
|
||||
var book dto.BookUserGetBook
|
||||
for _, b := range result.Books {
|
||||
if b.Title == "De sang-froid" {
|
||||
book = b
|
||||
}
|
||||
}
|
||||
assert.Equal(t,
|
||||
bookUserGetBook{
|
||||
BookId: 18,
|
||||
Title: "De sang-froid",
|
||||
Author: "Truman Capote",
|
||||
Rating: 6,
|
||||
Read: true,
|
||||
dto.BookUserGetBook{
|
||||
ID: 18,
|
||||
Title: "De sang-froid",
|
||||
Author: "Truman Capote",
|
||||
Rating: 6,
|
||||
Read: true,
|
||||
CoverPath: "/bookcover/desangfroid.jpg",
|
||||
}, book)
|
||||
}
|
||||
|
||||
func testGetReadBooksHandler(t *testing.T, router *gin.Engine, userToken string, expectedCode int, limit string, offset string) bookUserGet {
|
||||
func testGetReadBooksHandler(t *testing.T, router *gin.Engine, userToken string, expectedCode int, limit string, offset string) dto.BookUserGet {
|
||||
u, err := url.Parse("/mybooks/read")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user