(t *testing.T)
| 271 | } |
| 272 | |
| 273 | func TestNotificationDispatchMethods(t *testing.T) { |
| 274 | t.Parallel() |
| 275 | |
| 276 | defaultOpts := createOpts(t) |
| 277 | webhookOpts := createOpts(t) |
| 278 | webhookOpts.DeploymentValues.Notifications.Method = serpent.String(database.NotificationMethodWebhook) |
| 279 | |
| 280 | tests := []struct { |
| 281 | name string |
| 282 | opts *coderdtest.Options |
| 283 | expectedDefault string |
| 284 | }{ |
| 285 | { |
| 286 | name: "default", |
| 287 | opts: defaultOpts, |
| 288 | expectedDefault: string(database.NotificationMethodSmtp), |
| 289 | }, |
| 290 | { |
| 291 | name: "non-default", |
| 292 | opts: webhookOpts, |
| 293 | expectedDefault: string(database.NotificationMethodWebhook), |
| 294 | }, |
| 295 | } |
| 296 | |
| 297 | var allMethods []string |
| 298 | for _, nm := range database.AllNotificationMethodValues() { |
| 299 | if nm == database.NotificationMethodInbox { |
| 300 | continue |
| 301 | } |
| 302 | allMethods = append(allMethods, string(nm)) |
| 303 | } |
| 304 | slices.Sort(allMethods) |
| 305 | |
| 306 | // nolint:paralleltest // Not since Go v1.22. |
| 307 | for _, tc := range tests { |
| 308 | t.Run(tc.name, func(t *testing.T) { |
| 309 | t.Parallel() |
| 310 | |
| 311 | ctx := testutil.Context(t, testutil.WaitSuperLong) |
| 312 | api := coderdtest.New(t, tc.opts) |
| 313 | _ = coderdtest.CreateFirstUser(t, api) |
| 314 | |
| 315 | resp, err := api.GetNotificationDispatchMethods(ctx) |
| 316 | require.NoError(t, err) |
| 317 | |
| 318 | slices.Sort(resp.AvailableNotificationMethods) |
| 319 | require.EqualValues(t, resp.AvailableNotificationMethods, allMethods) |
| 320 | require.Equal(t, tc.expectedDefault, resp.DefaultNotificationMethod) |
| 321 | }) |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | func TestNotificationTest(t *testing.T) { |
| 326 | t.Parallel() |
nothing calls this directly
no test coverage detected