(t *testing.T, ctx context.Context, provider Provider)
| 324 | } |
| 325 | |
| 326 | func testWebhookOperations(t *testing.T, ctx context.Context, provider Provider) { |
| 327 | webhook := &schemas.Webhook{ |
| 328 | EventName: "test_event", |
| 329 | EndPoint: "https://test.com/webhook", |
| 330 | Enabled: true, |
| 331 | } |
| 332 | |
| 333 | // Test AddWebhook |
| 334 | created, err := provider.AddWebhook(ctx, webhook) |
| 335 | assert.NoError(t, err) |
| 336 | assert.NotNil(t, created) |
| 337 | |
| 338 | // Test GetWebhookByID |
| 339 | fetched, err := provider.GetWebhookByID(ctx, created.ID) |
| 340 | assert.NoError(t, err) |
| 341 | assert.Equal(t, webhook.EventName, fetched.EventName) |
| 342 | |
| 343 | // Test GetWebhookByEventName |
| 344 | fetchedByEventName, err := provider.GetWebhookByEventName(ctx, webhook.EventName) |
| 345 | assert.NoError(t, err) |
| 346 | assert.NotNil(t, fetchedByEventName) |
| 347 | assert.Equal(t, created.ID, fetchedByEventName[0].ID) |
| 348 | |
| 349 | // Test UpdateWebhook |
| 350 | webhook.EndPoint = "https://test.com/webhook_updated" |
| 351 | updated, err := provider.UpdateWebhook(ctx, webhook) |
| 352 | assert.NoError(t, err) |
| 353 | assert.Equal(t, webhook.EndPoint, updated.EndPoint) |
| 354 | |
| 355 | // Test ListWebhook |
| 356 | webhooks, _, err := provider.ListWebhook(ctx, &model.Pagination{ |
| 357 | Limit: 10, |
| 358 | Offset: 0, |
| 359 | }) |
| 360 | assert.NoError(t, err) |
| 361 | assert.NotNil(t, webhooks) |
| 362 | assert.Greater(t, len(webhooks), 0) |
| 363 | |
| 364 | // Test ListWebhookLogs |
| 365 | logs, _, err := provider.ListWebhookLogs(ctx, &model.Pagination{ |
| 366 | Limit: 10, |
| 367 | Offset: 0, |
| 368 | }, webhook.ID) |
| 369 | assert.NoError(t, err) |
| 370 | assert.NotNil(t, logs) |
| 371 | assert.Empty(t, len(logs)) |
| 372 | |
| 373 | // Test DeleteWebhook |
| 374 | err = provider.DeleteWebhook(ctx, updated) |
| 375 | assert.NoError(t, err) |
| 376 | } |
| 377 | |
| 378 | func testEmailTemplateOperations(t *testing.T, ctx context.Context, provider Provider) { |
| 379 | template := &schemas.EmailTemplate{ |
no test coverage detected