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

@ -38,6 +38,23 @@ func TestGoTemplate(t *testing.T) {
expectedOutput: userEmail,
expectedErr: nil,
},
{
name: "render workspace URL",
in: `[{
"label": "View workspace",
"url": "{{ base_url }}/@{{.UserName}}/{{.Labels.name}}"
}]`,
payload: types.MessagePayload{
UserName: "johndoe",
Labels: map[string]string{
"name": "my-workspace",
},
},
expectedOutput: `[{
"label": "View workspace",
"url": "https://mocked-server-address/@johndoe/my-workspace"
}]`,
},
}
for _, tc := range tests {
@ -46,7 +63,9 @@ func TestGoTemplate(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
out, err := render.GoTemplate(tc.in, tc.payload, nil)
out, err := render.GoTemplate(tc.in, tc.payload, map[string]any{
"base_url": func() string { return "https://mocked-server-address" },
})
if tc.expectedErr == nil {
require.NoError(t, err)
} else {