Create new collections from my collections view

This commit is contained in:
2026-04-03 15:51:18 +02:00
parent b1bad80426
commit b48ab1e4de
11 changed files with 185 additions and 27 deletions

View File

@@ -0,0 +1,31 @@
package apitest
import (
"net/http"
"testing"
"git.artlef.fr/bibliomane/internal/testutils"
"github.com/stretchr/testify/assert"
)
func TestPostCollectionHandler_Ok(t *testing.T) {
collectionJson :=
`{
"name": "My collection"
}`
status, _ := testPostCollectionHandler(t, collectionJson)
assert.Equal(t, http.StatusOK, status)
}
func TestPostCollectionHandler_NameTooLong(t *testing.T) {
collectionJson :=
`{
"name": "rsteerdemenschderraumschiffgebrauchlichtalsseinursprungvonkraftgestartseinlangefahrthinzwischensternartigraumaufdersuchenrsteerdemenschderraumschiffgebrauchlichtalsseinursprungvonkraftgestartseinlangefahrthinzwischensternartigraumaufdersuchenrsteerdemenschderraumschiffgebrauchlichtalsseinursprungvonkraftgestartseinlangefahrthinzwischensternartigraumaufdersuchen"
}`
status, _ := testPostCollectionHandler(t, collectionJson)
assert.Equal(t, http.StatusBadRequest, status)
}
func testPostCollectionHandler(t *testing.T, collectionJson string) (int, uint) {
return testutils.TestPostCall(t, "/ws/collection", collectionJson)
}