test: send Idempotency-Key in message helpers
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -174,20 +173,12 @@ func sendMessage(
|
|||||||
) *http.Response {
|
) *http.Response {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
body, err := json.Marshal(map[string]string{
|
resp, err := sendLoadMessage(actor, chatID, text)
|
||||||
"text": text,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("marshal message: %v", err)
|
t.Fatalf("send message: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return doRequest(
|
return resp
|
||||||
t,
|
|
||||||
http.MethodPost,
|
|
||||||
fmt.Sprintf("/api/v1/chats/%v/messages", chatID.String()),
|
|
||||||
actor.Token,
|
|
||||||
body,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendLoadMessage(
|
func sendLoadMessage(
|
||||||
@@ -213,6 +204,7 @@ func sendLoadMessage(
|
|||||||
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
req.Header.Set("Authorization", "Bearer "+actor.Token)
|
req.Header.Set("Authorization", "Bearer "+actor.Token)
|
||||||
|
req.Header.Set("Idempotency-Key", uuid.NewString())
|
||||||
|
|
||||||
return httpClient.Do(req)
|
return httpClient.Do(req)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user