1.3 KiB
1.3 KiB
QA procedure: upload_article_image
Package: test (black-box, extending article_test.go / image_test.go).
Setup shared by every case
- Call
validator.InitValidator()once. - Wire
image.NewHandler(createImageUseCase, getArticleUseCase)(no update or delete use cases) and mount onlyPOST /{id}/imagein the article group, behindVerifier,Authenticator,RequireCurrentToken,RequireVerifiedUser. - Use real image bytes generated in the test, as in
media_library.qa.mdstep 8, and multipart bodies with an explicit partContent-Type.
HTTP checks
- Valid PNG on article 1 -> 201
{id, location}matching the created image, andarticleRepo.articles[1]has an unchanged body. - Unknown article 9999 -> 404
"Article not found\n",Createnever called. - Rejected files:
application/pdf-> 415, PNG padded to 10485761 bytes -> 413, text bytes asimage/png-> 400;Createnever called. - No cookie -> 401,
Createnever called. DELETE /v1/article/1/image/10on this router -> 405, image 10 still exists.
Cleanup
Delete test/remove_article_image_http_test.go and update test/upload_article_image_http_test.go to the cases above.
Manual verification
With a real instance, POST /v1/article/{id}/image writes a file to UPLOAD_DIR and a row visible in GET /v1/media/, and no article association is written.