From 17ad9b691f2335e8e5d1c2d922665c373078293c Mon Sep 17 00:00:00 2001 From: kk10 Date: Sat, 17 Oct 2026 11:27:56 +0300 Subject: [PATCH] test: send Idempotency-Key in message helpers --- student-tests/helpers_test.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/student-tests/helpers_test.go b/student-tests/helpers_test.go index b97f4d5..245cf0d 100644 --- a/student-tests/helpers_test.go +++ b/student-tests/helpers_test.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "flag" - "fmt" "io" "net/http" "strings" @@ -174,20 +173,12 @@ func sendMessage( ) *http.Response { t.Helper() - body, err := json.Marshal(map[string]string{ - "text": text, - }) + resp, err := sendLoadMessage(actor, chatID, text) if err != nil { - t.Fatalf("marshal message: %v", err) + t.Fatalf("send message: %v", err) } - return doRequest( - t, - http.MethodPost, - fmt.Sprintf("/api/v1/chats/%v/messages", chatID.String()), - actor.Token, - body, - ) + return resp } func sendLoadMessage( @@ -213,6 +204,7 @@ func sendLoadMessage( req.Header.Set("Content-Type", "application/json") req.Header.Set("Authorization", "Bearer "+actor.Token) + req.Header.Set("Idempotency-Key", uuid.NewString()) return httpClient.Do(req) }