feat: remove the 10,000-character article body limit and make the New article body optional
This commit is contained in:
1 parent
5e05b606a7
commit
10ec74c8cf
28 files changed
+860
-397
No files matched your search
@@ -164,31 +164,6 @@ func TestEditArticleBodyHttp(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
validationCases := []struct {
|
||||
name string
|
||||
payload string
|
||||
}{
|
||||
{"empty body", `{"body": ""}`},
|
||||
{"body over 10000 characters", `{"body": "` + strings.Repeat("a", 10001) + `"}`},
|
||||
}
|
||||
for _, tc := range validationCases {
|
||||
t.Run("A body value that fails validation answers 400: "+tc.name, func(t *testing.T) {
|
||||
repo := newEditArticleBodyTestRepo()
|
||||
router := newEditArticleBodyRouter(repo, token)
|
||||
req := newEditArticleBodyRequest(http.MethodPatch, "/v1/article/1", tc.payload)
|
||||
setEditArticleBodyJwtCookie(t, req, token)
|
||||
rec := httptest.NewRecorder()
|
||||
router.ServeHTTP(rec, req)
|
||||
|
||||
if rec.Code != http.StatusBadRequest {
|
||||
t.Fatalf("expected status 400, got %d", rec.Code)
|
||||
}
|
||||
if repo.articles[1].Body != "Old body text" {
|
||||
t.Errorf("expected stored body to be unchanged, got %q", repo.articles[1].Body)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
t.Run("A response write failure is logged", func(t *testing.T) {
|
||||
repo := newEditArticleBodyTestRepo()
|
||||
router := newEditArticleBodyRouter(repo, token)
|
||||
|
||||
Reference in new issue
Block a user