diff --git a/notifier.go b/notifier.go index 693cb2e..2ab4669 100644 --- a/notifier.go +++ b/notifier.go @@ -39,7 +39,7 @@ func formatPlain(d RequestData) string { // formatMarkdown — обёртка в код-блок для Telegram/Pachca. func formatMarkdown(d RequestData) string { - return "```" + formatPlain(d) + "```" + return "```\n" + formatPlain(d) + "```" } // formatHTML — обёртка в
с экранированием для Email.
diff --git a/notifier_test.go b/notifier_test.go
index f322223..bdad48a 100644
--- a/notifier_test.go
+++ b/notifier_test.go
@@ -25,8 +25,14 @@ func sampleData() RequestData {
func TestFormatMarkdown(t *testing.T) {
out := formatMarkdown(sampleData())
- if !strings.HasPrefix(out, "```") || !strings.HasSuffix(out, "```") {
- t.Fatalf("expected ``` wrapping, got: %q", out)
+ if !strings.HasPrefix(out, "```\n") || !strings.HasSuffix(out, "```") {
+ // Перевод строки после открывающего фенса обязателен: иначе markdown
+ // в Pachca/Telegram съедает первую строку как указатель языка, и путь
+ // запроса (METHOD host/url) пропадает из уведомления.
+ t.Fatalf("expected ```\\n wrapping, got: %q", out)
+ }
+ if !strings.Contains(out, "/telegram") {
+ t.Errorf("missing request path/url: %q", out)
}
if !strings.Contains(out, "POST") || !strings.Contains(out, "1.2.3.4") {
t.Errorf("missing fields: %q", out)