Make "want read" button work
This commit is contained in:
@@ -2,14 +2,17 @@ package testutils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/config"
|
||||
"git.artlef.fr/PersonalLibraryManager/internal/setup"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestSetup() *gin.Engine {
|
||||
@@ -51,3 +54,13 @@ func connectUser(router *gin.Engine, loginJson string) string {
|
||||
}
|
||||
return parsedResponse.Token
|
||||
}
|
||||
|
||||
func TestBookPutCallWithDemoPayload(t *testing.T, payload string, bookId string, expectedCode int, url string) {
|
||||
router := TestSetup()
|
||||
token := ConnectDemoUser(router)
|
||||
req, _ := http.NewRequest("PUT", url, strings.NewReader(payload))
|
||||
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
|
||||
w := httptest.NewRecorder()
|
||||
router.ServeHTTP(w, req)
|
||||
assert.Equal(t, expectedCode, w.Code)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user