forked from mtusi2026/mtusi2026lab5
test(worker): add retry and persistence checks and adapt attachment tests for async processing
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
@@ -29,14 +30,16 @@ func TestAttachmentJPEG(t *testing.T) {
|
||||
}
|
||||
|
||||
resp := uploadAttachment(t, user, chat.ID, "sample.jpg", "image/jpeg", body.Bytes())
|
||||
requireStatus(t, resp, http.StatusCreated)
|
||||
requireStatus(t, resp, http.StatusAccepted)
|
||||
|
||||
var att dto.AttachmentResponse
|
||||
mustDecode(t, resp, &att)
|
||||
if att.Status != "ready" {
|
||||
t.Fatalf("expected ready attachment, got %q", att.Status)
|
||||
if att.Status != "queued" {
|
||||
t.Fatalf("expected queued attachment, got %q", att.Status)
|
||||
}
|
||||
|
||||
waitAttachment(t, user, att.ID, "ready", time.Minute)
|
||||
|
||||
resp = doRequest(t, http.MethodGet, "/api/v1/attachments/"+att.ID.String()+"/content", user.Token, nil)
|
||||
requireStatus(t, resp, http.StatusOK)
|
||||
defer resp.Body.Close()
|
||||
|
||||
Reference in New Issue
Block a user