feat: api - /api/v2/versions/{versionCode}/servers/{serverKey}/villages - add one more test
ci/woodpecker/push/govulncheck Pipeline was successful Details
ci/woodpecker/push/test Pipeline was successful Details

This commit is contained in:
Dawid Wysokiński 2024-03-06 08:16:29 +01:00
parent 53db131fec
commit 6ffc1f4ce4
Signed by: Kichiyaki
GPG Key ID: B5445E357FB8B892
1 changed files with 38 additions and 0 deletions

View File

@ -340,6 +340,44 @@ func TestListVillages(t *testing.T) {
}, body)
},
},
{
name: "ERR: len(coords) > 200",
reqModifier: func(t *testing.T, req *http.Request) {
t.Helper()
q := req.URL.Query()
for range 201 {
q.Add("coords", gofakeit.LetterN(50))
}
req.URL.RawQuery = q.Encode()
},
assertResp: func(t *testing.T, req *http.Request, resp *http.Response) {
t.Helper()
assert.Equal(t, http.StatusBadRequest, resp.StatusCode)
// body
body := decodeJSON[apimodel.ErrorResponse](t, resp.Body)
domainErr := domain.LenOutOfRangeError{
Min: 0,
Max: 200,
Current: len(req.URL.Query()["coords"]),
}
assert.Equal(t, apimodel.ErrorResponse{
Errors: []apimodel.Error{
{
Code: domainErr.Code(),
Message: domainErr.Error(),
Params: map[string]any{
"current": float64(domainErr.Current),
"max": float64(domainErr.Max),
"min": float64(domainErr.Min),
},
Path: []string{"$query", "coords"},
},
},
}, body)
},
},
{
name: "ERR: invalid coords string",
reqModifier: func(t *testing.T, req *http.Request) {