Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
One more test
  • Loading branch information
mtojek committed Jul 16, 2024
commit 3dd09d22f69f6b00e2e49faf5f09277168bbd4b4
11 changes: 7 additions & 4 deletions coderd/notifications/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down