Create new collections from my collections view
This commit is contained in:
31
internal/apitest/post_collection_test.go
Normal file
31
internal/apitest/post_collection_test.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user