Files
aura-crm/production/backend/internal/notify/handler_test.go
T

30 lines
849 B
Go

package notify
import (
"context"
"io"
"strings"
"testing"
)
func TestBuildSendRequestTargetsConfiguredBotAndChat(t *testing.T) {
req, err := buildSendRequest(context.Background(), "hello staff", "abc123", "-100987", "http://bot-api:8081")
if err != nil {
t.Fatalf("buildSendRequest returned error: %v", err)
}
wantURL := "http://bot-api:8081/botabc123/sendMessage"
if req.URL.String() != wantURL {
t.Errorf("URL = %q, want %q", req.URL.String(), wantURL)
}
body, _ := io.ReadAll(req.Body)
if !strings.Contains(string(body), `"chat_id":"-100987"`) {
t.Errorf("body missing chat_id: %s", body)
}
if !strings.Contains(string(body), `"hello staff"`) {
t.Errorf("body missing text: %s", body)
}
if ct := req.Header.Get("Content-Type"); ct != "application/json" {
t.Errorf("Content-Type = %q, want application/json", ct)
}
}