This commit is contained in:
binwiederhier
2025-07-16 20:33:52 +02:00
parent b1e935da45
commit 610792b902
8 changed files with 2640 additions and 34 deletions

View File

@@ -4,6 +4,7 @@ import (
"bufio"
"context"
"crypto/rand"
_ "embed"
"encoding/base64"
"encoding/json"
"fmt"
@@ -3069,6 +3070,23 @@ func TestServer_MessageTemplate_UnsafeSprigFunctions(t *testing.T) {
require.Equal(t, 40043, toHTTPError(t, response.Body.String()).Code)
}
var (
//go:embed testdata/webhook_github_comment_created.json
githubCommentCreatedJSON string
)
func TestServer_MessageTemplate_FromNamedTemplate(t *testing.T) {
t.Parallel()
s := newTestServer(t, newTestConfig(t))
response := request(t, s, "POST", "/mytopic", githubCommentCreatedJSON, map[string]string{
"Template": "github",
})
require.Equal(t, 200, response.Code)
m := toMessage(t, response.Body.String())
require.Equal(t, "💬 New comment on issue #1389 — instant alerts without Pull to refresh", m.Title)
require.Equal(t, "💬 New comment on issue #1389 — instant alerts without Pull to refresh", m.Message)
}
func newTestConfig(t *testing.T) *Config {
conf := NewConfig()
conf.BaseURL = "http://127.0.0.1:12345"