mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-07-19 11:09:26 +00:00
test: assert 404 via raw string client in messaging REST test
presto's typed REST client raises RestDecodingError when it cannot decode a non-2xx text error body into the response type. Add a RestResponse[string] stub (messagingGetSendEventsByIdRawV1) and point the "already-polled id -> 404" assertion at it, matching the relay REST test pattern. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
5e54ed8007
commit
d194b6605f
@ -50,6 +50,14 @@ proc messagingGetSendEventsByIdV1*(
|
||||
rest, endpoint: "/messaging/v1/events/send/{requestId}", meth: HttpMethod.MethodGet
|
||||
.}
|
||||
|
||||
# Raw variant: the typed client above cannot decode a non-2xx text error body,
|
||||
# so status-code assertions (e.g. 404) use this string form.
|
||||
proc messagingGetSendEventsByIdRawV1*(
|
||||
requestId: string
|
||||
): RestResponse[string] {.
|
||||
rest, endpoint: "/messaging/v1/events/send/{requestId}", meth: HttpMethod.MethodGet
|
||||
.}
|
||||
|
||||
proc messagingGetReceivedMessagesV1*(): RestResponse[seq[ReceivedMessageRecord]] {.
|
||||
rest, endpoint: "/messaging/v1/events/received", meth: HttpMethod.MethodGet
|
||||
.}
|
||||
|
||||
@ -11,6 +11,7 @@ import brokers/broker_context
|
||||
import logos_delivery
|
||||
import
|
||||
logos_delivery/messaging/rest_api/client as messaging_rest_client,
|
||||
logos_delivery/waku/rest_api/endpoint/client,
|
||||
logos_delivery/waku/common/base64
|
||||
import tools/confutils/cli_args
|
||||
import ../testlib/[wakucore, testasync]
|
||||
@ -99,8 +100,7 @@ suite "Messaging REST API":
|
||||
brokerCtx, MessageSentEvent(requestId: reqA, messageHash: "0xaa")
|
||||
)
|
||||
MessageErrorEvent.emit(
|
||||
brokerCtx,
|
||||
MessageErrorEvent(requestId: reqB, messageHash: "0xbb", error: "boom"),
|
||||
brokerCtx, MessageErrorEvent(requestId: reqB, messageHash: "0xbb", error: "boom")
|
||||
)
|
||||
await sleepAsync(settleDelay)
|
||||
|
||||
@ -113,8 +113,9 @@ suite "Messaging REST API":
|
||||
byIdResp.data.events.anyIt(it.kind == SendEventKind.Sent)
|
||||
byIdResp.data.events.anyIt(it.kind == SendEventKind.Propagated)
|
||||
|
||||
# Unknown / already-polled id → 404.
|
||||
let missingResp = await client.messagingGetSendEventsByIdV1($reqA)
|
||||
# Unknown / already-polled id → 404 (raw string client so the text error
|
||||
# body decodes; the typed client would raise on a non-2xx body).
|
||||
let missingResp = await client.messagingGetSendEventsByIdRawV1($reqA)
|
||||
check missingResp.status == 404
|
||||
|
||||
# GET all now returns only reqB (with its error), then clears.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user