feat: notify owner about failed autobuild (#13891)

This commit is contained in:
Marcin Tojek
2024-07-16 10:48:17 +02:00
committed by GitHub
parent 36454aa81b
commit a5e4bf38fe
8 changed files with 204 additions and 25 deletions

View File

@ -98,10 +98,11 @@ func TestBuildPayload(t *testing.T) {
// GIVEN: a set of helpers to be injected into the templates
const label = "Click here!"
const url = "http://xyz.com/"
const baseURL = "http://xyz.com"
const url = baseURL + "/@bobby/my-workspace"
helpers := map[string]any{
"my_label": func() string { return label },
"my_url": func() string { return url },
"my_url": func() string { return baseURL },
}
// GIVEN: an enqueue interceptor which returns mock metadata
@ -112,7 +113,7 @@ func TestBuildPayload(t *testing.T) {
actions := []types.TemplateAction{
{
Label: "{{ my_label }}",
URL: "{{ my_url }}",
URL: "{{ my_url }}/@{{.UserName}}/{{.Labels.name}}",
},
}
out, err := json.Marshal(actions)
@ -131,7 +132,9 @@ func TestBuildPayload(t *testing.T) {
require.NoError(t, err)
// WHEN: a notification is enqueued
_, err = enq.Enqueue(ctx, uuid.New(), notifications.TemplateWorkspaceDeleted, nil, "test")
_, err = enq.Enqueue(ctx, uuid.New(), notifications.TemplateWorkspaceDeleted, map[string]string{
"name": "my-workspace",
}, "test")
require.NoError(t, err)
// THEN: expect that a payload will be constructed and have the expected values