1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-07-17 11:07:42 +02:00

removed DrySubmit form errors wrapping and added more api tests

This commit is contained in:
Gani Georgiev
2022-11-01 00:28:33 +02:00
parent 5298543ce4
commit 9cef6ebd82
4 changed files with 32 additions and 8 deletions

View File

@ -818,6 +818,14 @@ func TestRecordCrudCreate(t *testing.T) {
ExpectedStatus: 403,
ExpectedContent: []string{`"data":{}`},
},
{
Name: "submit nil body",
Method: http.MethodPost,
Url: "/api/collections/demo2/records",
Body: nil,
ExpectedStatus: 400,
ExpectedContent: []string{`"data":{}`},
},
{
Name: "submit invalid format",
Method: http.MethodPost,
@ -827,12 +835,17 @@ func TestRecordCrudCreate(t *testing.T) {
ExpectedContent: []string{`"data":{}`},
},
{
Name: "submit nil body",
Method: http.MethodPost,
Url: "/api/collections/demo2/records",
Body: nil,
ExpectedStatus: 400,
ExpectedContent: []string{`"data":{}`},
Name: "submit empty json body",
Method: http.MethodPost,
Url: "/api/collections/nologin/records",
Body: strings.NewReader(`{}`),
ExpectedStatus: 400,
ExpectedContent: []string{
`"data":{`,
`"email":{"code":"validation_required"`,
`"password":{"code":"validation_required"`,
`"passwordConfirm":{"code":"validation_required"`,
},
},
{
Name: "guest submit in public collection",
@ -1316,6 +1329,17 @@ func TestRecordCrudUpdate(t *testing.T) {
"OnRecordBeforeUpdateRequest": 1,
},
},
{
Name: "trigger field validation",
Method: http.MethodPatch,
Url: "/api/collections/demo2/records/0yxhwia2amd8gec",
Body: strings.NewReader(`{"title":"a"}`),
ExpectedStatus: 400,
ExpectedContent: []string{
`data":{`,
`"title":{"code":"validation_min_text_constraint"`,
},
},
{
Name: "guest submit in public collection",
Method: http.MethodPatch,