@@ -778,21 +778,7 @@ func TestWorkspaceService_DeleteWorkspace(t *testing.T) {
778778 mockRepo .EXPECT ().GetUserWorkspace (ctx , userID , workspaceID ).Return (userWorkspace , nil ).Times (2 )
779779 mockRepo .EXPECT ().GetByID (ctx , workspaceID ).Return (workspace , nil ).Times (2 )
780780
781- // For first integration
782- webhookStatus1 := & domain.WebhookRegistrationStatus {
783- EmailProviderKind : domain .EmailProviderKindSMTP ,
784- IsRegistered : true ,
785- }
786- mockWebhookRegService .EXPECT ().GetWebhookStatus (ctx , workspaceID , "integration-1" ).Return (webhookStatus1 , nil )
787- mockWebhookRegService .EXPECT ().UnregisterWebhooks (ctx , workspaceID , "integration-1" ).Return (nil )
788-
789- // For second integration
790- webhookStatus2 := & domain.WebhookRegistrationStatus {
791- EmailProviderKind : domain .EmailProviderKindSMTP ,
792- IsRegistered : true ,
793- }
794- mockWebhookRegService .EXPECT ().GetWebhookStatus (ctx , workspaceID , "integration-2" ).Return (webhookStatus2 , nil )
795- mockWebhookRegService .EXPECT ().UnregisterWebhooks (ctx , workspaceID , "integration-2" ).Return (nil )
781+ // No webhook operations expected for SMTP integrations
796782
797783 // Once for each integration deletion
798784 mockRepo .EXPECT ().Update (ctx , gomock .Any ()).Return (nil ).Times (2 )
@@ -843,13 +829,7 @@ func TestWorkspaceService_DeleteWorkspace(t *testing.T) {
843829 mockRepo .EXPECT ().GetUserWorkspace (ctx , userID , workspaceID ).Return (userWorkspace , nil )
844830 mockRepo .EXPECT ().GetByID (ctx , workspaceID ).Return (workspace , nil )
845831
846- // The integration deletion fails
847- webhookStatus := & domain.WebhookRegistrationStatus {
848- EmailProviderKind : domain .EmailProviderKindSMTP ,
849- IsRegistered : true ,
850- }
851- mockWebhookRegService .EXPECT ().GetWebhookStatus (ctx , workspaceID , "integration-1" ).Return (webhookStatus , nil )
852- mockWebhookRegService .EXPECT ().UnregisterWebhooks (ctx , workspaceID , "integration-1" ).Return (errors .New ("webhook error" ))
832+ // No webhook operations expected for SMTP integrations
853833 // The update fails
854834 mockRepo .EXPECT ().Update (ctx , gomock .Any ()).Return (errors .New ("integration delete error" ))
855835
@@ -984,25 +964,8 @@ func TestWorkspaceService_CreateIntegration(t *testing.T) {
984964 return nil
985965 })
986966
987- // Expect webhook registration call for email integration
967+ // No webhook registration expected for SMTP provider
988968 mockConfig .APIEndpoint = "https://api.example.com"
989- // Webhook config is provided for reference only, we use gomock.Any() since ID is random
990- _ = & domain.WebhookRegistrationConfig {
991- IntegrationID : "integration123" , // This will be a random UUID, so use Any matcher
992- EventTypes : []domain.EmailEventType {
993- domain .EmailEventDelivered ,
994- domain .EmailEventBounce ,
995- domain .EmailEventComplaint ,
996- },
997- }
998- mockWebhookRegService .EXPECT ().RegisterWebhooks (
999- ctx ,
1000- workspaceID ,
1001- gomock .Any (), // Use Any for the config since integrationID is random
1002- ).Return (& domain.WebhookRegistrationStatus {
1003- EmailProviderKind : domain .EmailProviderKindSMTP ,
1004- IsRegistered : true ,
1005- }, nil )
1006969
1007970 integrationID , err := service .CreateIntegration (ctx , workspaceID , integrationName , domain .IntegrationTypeEmail , provider )
1008971 require .NoError (t , err )
@@ -1328,21 +1291,7 @@ func TestWorkspaceService_DeleteIntegration(t *testing.T) {
13281291 mockRepo .EXPECT ().GetUserWorkspace (ctx , userID , workspaceID ).Return (expectedUserWorkspace , nil )
13291292 mockRepo .EXPECT ().GetByID (ctx , workspaceID ).Return (expectedWorkspace , nil )
13301293
1331- // Expect webhook status check
1332- webhookStatus := & domain.WebhookRegistrationStatus {
1333- EmailProviderKind : domain .EmailProviderKindSMTP ,
1334- IsRegistered : true ,
1335- Endpoints : []domain.WebhookEndpointStatus {
1336- {
1337- URL : "https://api.example.com/webhooks" ,
1338- Active : true ,
1339- },
1340- },
1341- }
1342- mockWebhookRegService .EXPECT ().GetWebhookStatus (ctx , workspaceID , integrationID ).Return (webhookStatus , nil )
1343-
1344- // Expect webhook unregistration
1345- mockWebhookRegService .EXPECT ().UnregisterWebhooks (ctx , workspaceID , integrationID ).Return (nil )
1294+ // No webhook operations expected for SMTP provider
13461295
13471296 mockRepo .EXPECT ().Update (ctx , gomock .Any ()).DoAndReturn (func (ctx context.Context , workspace * domain.Workspace ) error {
13481297 // Verify the integration was removed from the workspace
@@ -1440,25 +1389,7 @@ func TestWorkspaceService_DeleteIntegration(t *testing.T) {
14401389 mockRepo .EXPECT ().GetUserWorkspace (ctx , userID , workspaceID ).Return (expectedUserWorkspace , nil )
14411390 mockRepo .EXPECT ().GetByID (ctx , workspaceID ).Return (expectedWorkspace , nil )
14421391
1443- // Expect webhook status check
1444- mockWebhookRegService .EXPECT ().GetWebhookStatus (ctx , workspaceID , integrationID ).Return (& domain.WebhookRegistrationStatus {
1445- EmailProviderKind : domain .EmailProviderKindSMTP ,
1446- IsRegistered : true ,
1447- Endpoints : []domain.WebhookEndpointStatus {
1448- {
1449- URL : "https://api.example.com/webhooks" ,
1450- Active : true ,
1451- },
1452- },
1453- }, nil )
1454-
1455- // Skip logger checks
1456-
1457- // The unregistration fails
1458- webhookError := errors .New ("failed to unregister webhooks" )
1459- mockWebhookRegService .EXPECT ().UnregisterWebhooks (ctx , workspaceID , integrationID ).Return (webhookError )
1460-
1461- // Skip logger checks
1392+ // No webhook operations expected for SMTP provider
14621393
14631394 mockRepo .EXPECT ().Update (ctx , gomock .Any ()).Return (nil )
14641395
@@ -1500,11 +1431,7 @@ func TestWorkspaceService_DeleteIntegration(t *testing.T) {
15001431 mockRepo .EXPECT ().GetUserWorkspace (ctx , userID , workspaceID ).Return (expectedUserWorkspace , nil )
15011432 mockRepo .EXPECT ().GetByID (ctx , workspaceID ).Return (expectedWorkspace , nil )
15021433
1503- // Expect webhook status check
1504- mockWebhookRegService .EXPECT ().GetWebhookStatus (ctx , workspaceID , integrationID ).Return (& domain.WebhookRegistrationStatus {
1505- EmailProviderKind : domain .EmailProviderKindSMTP ,
1506- IsRegistered : false , // Not registered
1507- }, nil )
1434+ // No webhook operations expected for SMTP provider
15081435
15091436 mockRepo .EXPECT ().Update (ctx , gomock .Any ()).DoAndReturn (func (ctx context.Context , workspace * domain.Workspace ) error {
15101437 // Verify the reference was removed from settings
0 commit comments