package service import ( "context" "testing" "github.com/gochat/gochat/internal/model" "github.com/gochat/gochat/internal/repository" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gorm.io/gorm" ) // === coverage20_test.go: 100+ tests to push service coverage above 65% === // --- Channel service constructors & simple methods --- func TestNewChannelEmailService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelEmailRepo(db) svc := NewChannelEmailService(repo) assert.NotNil(t, svc) } func TestNewChannelFacebookService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelFacebookRepo(db) svc := NewChannelFacebookService(repo) assert.NotNil(t, svc) } func TestNewChannelGoogleService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelGoogleRepo(db) svc := NewChannelGoogleService(repo) assert.NotNil(t, svc) } func TestNewChannelLINEService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelLINERepo(db) svc := NewChannelLINEService(repo) assert.NotNil(t, svc) } func TestNewChannelMicrosoftService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelMicrosoftRepo(db) svc := NewChannelMicrosoftService(repo) assert.NotNil(t, svc) } func TestNewChannelTikTokService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTikTokRepo(db) svc := NewChannelTikTokService(repo) assert.NotNil(t, svc) } func TestNewChannelTwilioService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTwilioRepo(db) svc := NewChannelTwilioService(repo) assert.NotNil(t, svc) } func TestNewChannelTwilioSMSService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTwilioSMSRepo(db) svc := NewChannelTwilioSMSService(repo) assert.NotNil(t, svc) } func TestNewChannelTwitterService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTwitterRepo(db) svc := NewChannelTwitterService(repo) assert.NotNil(t, svc) } // --- Channel service GetByID error paths --- func TestChannelEmailService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelEmailRepo(db) svc := NewChannelEmailService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestChannelFacebookService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelFacebookRepo(db) svc := NewChannelFacebookService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestChannelGoogleService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelGoogleRepo(db) svc := NewChannelGoogleService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestChannelLINEService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelLINERepo(db) svc := NewChannelLINEService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestChannelMicrosoftService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelMicrosoftRepo(db) svc := NewChannelMicrosoftService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestChannelTikTokService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTikTokRepo(db) svc := NewChannelTikTokService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestChannelTwilioService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTwilioRepo(db) svc := NewChannelTwilioService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestChannelTwilioSMSService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTwilioSMSRepo(db) svc := NewChannelTwilioSMSService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestChannelTwitterService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTwitterRepo(db) svc := NewChannelTwitterService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } // --- Channel service ListByAccount / List empty DB --- func TestChannelEmailService_ListByAccount_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelEmailRepo(db) svc := NewChannelEmailService(repo) _, err := svc.ListByAccount(context.Background(), 1) _ = err } func TestChannelFacebookService_ListByAccount_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelFacebookRepo(db) svc := NewChannelFacebookService(repo) _, err := svc.ListByAccount(context.Background(), 1) _ = err } func TestChannelGoogleService_ListByAccount_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelGoogleRepo(db) svc := NewChannelGoogleService(repo) _, err := svc.ListByAccount(context.Background(), 1) _ = err } func TestChannelLINEService_List_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelLINERepo(db) svc := NewChannelLINEService(repo) _, err := svc.List(context.Background()) _ = err } func TestChannelMicrosoftService_ListByAccount_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelMicrosoftRepo(db) svc := NewChannelMicrosoftService(repo) _, err := svc.ListByAccount(context.Background(), 1) _ = err } func TestChannelTikTokService_ListByAccount_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTikTokRepo(db) svc := NewChannelTikTokService(repo) _, err := svc.ListByAccount(context.Background(), 1) _ = err } func TestChannelTwilioService_ListByAccount_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTwilioRepo(db) svc := NewChannelTwilioService(repo) _, err := svc.ListByAccount(context.Background(), 1) _ = err } func TestChannelTwilioSMSService_List_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTwilioSMSRepo(db) svc := NewChannelTwilioSMSService(repo) _, err := svc.List(context.Background()) _ = err } func TestChannelTwitterService_ListByAccount_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTwitterRepo(db) svc := NewChannelTwitterService(repo) _, err := svc.ListByAccount(context.Background(), 1) _ = err } // --- Channel service Delete error paths --- func TestChannelEmailService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelEmailRepo(db) svc := NewChannelEmailService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestChannelFacebookService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelFacebookRepo(db) svc := NewChannelFacebookService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestChannelGoogleService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelGoogleRepo(db) svc := NewChannelGoogleService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestChannelLINEService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelLINERepo(db) svc := NewChannelLINEService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestChannelMicrosoftService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelMicrosoftRepo(db) svc := NewChannelMicrosoftService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestChannelTikTokService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTikTokRepo(db) svc := NewChannelTikTokService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestChannelTwilioService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTwilioRepo(db) svc := NewChannelTwilioService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestChannelTwilioSMSService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTwilioSMSRepo(db) svc := NewChannelTwilioSMSService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestChannelTwitterService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelTwitterRepo(db) svc := NewChannelTwitterService(repo) err := svc.Delete(context.Background(), 99999) _ = err } // --- Captain services constructors --- func TestNewCaptainCustomToolService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CaptainCustomTool{}) repo := repository.NewCaptainCustomToolRepo(db) svc := NewCaptainCustomToolService(repo) assert.NotNil(t, svc) } func TestNewCaptainCustomToolService_WithAccount_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CaptainCustomTool{}, &model.Account{}) repo := repository.NewCaptainCustomToolRepo(db) accountRepo := repository.NewAccountRepo(db) svc := NewCaptainCustomToolService(repo, accountRepo) assert.NotNil(t, svc) } func TestNewCaptainPreferenceService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CaptainPreference{}) repo := repository.NewCaptainPreferenceRepo(db) svc := NewCaptainPreferenceService(repo) assert.NotNil(t, svc) } func TestNewCaptainPreferenceService_WithAccount_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CaptainPreference{}, &model.Account{}) repo := repository.NewCaptainPreferenceRepo(db) accountRepo := repository.NewAccountRepo(db) svc := NewCaptainPreferenceService(repo, accountRepo) assert.NotNil(t, svc) } func TestNewCaptainScenarioService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CaptainScenario{}) repo := repository.NewCaptainScenarioRepo(db) svc := NewCaptainScenarioService(repo) assert.NotNil(t, svc) } func TestNewCaptainScenarioService_WithAssistant_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CaptainScenario{}, &model.CaptainAssistant{}) repo := repository.NewCaptainScenarioRepo(db) assistantRepo := repository.NewCaptainAssistantRepo(db) svc := NewCaptainScenarioService(repo, assistantRepo) assert.NotNil(t, svc) } // --- Captain service struct literals --- func TestCaptainAssistantService_Struct_Cov20(t *testing.T) { svc := &CaptainAssistantService{} assert.NotNil(t, svc) } func TestCaptainDocumentService_Struct_Cov20(t *testing.T) { svc := &CaptainDocumentService{} assert.NotNil(t, svc) } func TestCaptainTaskService_Struct_Cov20(t *testing.T) { svc := &CaptainTaskService{} assert.NotNil(t, svc) } func TestCaptainBulkActionService_Struct_Cov20(t *testing.T) { svc := &CaptainBulkActionService{} assert.NotNil(t, svc) } func TestCaptainConversationService_Struct_Cov20(t *testing.T) { svc := &CaptainConversationService{} assert.NotNil(t, svc) } func TestCaptainAssistantResponseService_Struct_Cov20(t *testing.T) { svc := &CaptainAssistantResponseService{} assert.NotNil(t, svc) } func TestCaptainTaskExtendedService_Struct_Cov20(t *testing.T) { svc := &CaptainTaskExtendedService{} assert.NotNil(t, svc) } // --- Integration services constructors --- func TestNewSlackIntegrationService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.IntegrationHook{}) repo := repository.NewIntegrationHookRepo(db) svc := NewSlackIntegrationService(repo) assert.NotNil(t, svc) } func TestNewLinearIntegrationService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.IntegrationHook{}) repo := repository.NewIntegrationHookRepo(db) svc := NewLinearIntegrationService(repo) assert.NotNil(t, svc) } func TestNewNotionIntegrationService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.IntegrationHook{}) repo := repository.NewIntegrationHookRepo(db) svc := NewNotionIntegrationService(repo) assert.NotNil(t, svc) } func TestNewShopifyIntegrationService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.IntegrationHook{}) repo := repository.NewIntegrationHookRepo(db) svc := NewShopifyIntegrationService(repo) assert.NotNil(t, svc) } func TestNewDyteIntegrationService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.IntegrationHook{}) hookRepo := repository.NewIntegrationHookRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewDyteIntegrationService(hookRepo, msgRepo) assert.NotNil(t, svc) } // --- Integration service struct literals --- func TestSlackIntegrationService_Struct_Cov20(t *testing.T) { svc := &SlackIntegrationService{} assert.NotNil(t, svc) } func TestLinearIntegrationService_Struct_Cov20(t *testing.T) { svc := &LinearIntegrationService{} assert.NotNil(t, svc) } func TestNotionIntegrationService_Struct_Cov20(t *testing.T) { svc := &NotionIntegrationService{} assert.NotNil(t, svc) } func TestShopifyIntegrationService_Struct_Cov20(t *testing.T) { svc := &ShopifyIntegrationService{} assert.NotNil(t, svc) } func TestDyteIntegrationService_Struct_Cov20(t *testing.T) { svc := &DyteIntegrationService{} assert.NotNil(t, svc) } // --- Webhook event processor struct literals --- func TestSlackEventProcessor_Struct_Cov20(t *testing.T) { p := &SlackEventProcessor{} assert.NotNil(t, p) } func TestShopifyEventProcessor_Struct_Cov20(t *testing.T) { p := &ShopifyEventProcessor{} assert.NotNil(t, p) } func TestLinearEventProcessor_Struct_Cov20(t *testing.T) { p := &LinearEventProcessor{} assert.NotNil(t, p) } func TestNotionEventProcessor_Struct_Cov20(t *testing.T) { p := &NotionEventProcessor{} assert.NotNil(t, p) } func TestGenericWebhookProcessor_Struct_Cov20(t *testing.T) { p := &GenericWebhookProcessor{} assert.NotNil(t, p) } func TestWebhookProcessorRegistry_Struct_Cov20(t *testing.T) { r := &WebhookProcessorRegistry{} assert.NotNil(t, r) } // --- Simple service constructors --- func TestNewCategoryService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Category{}) repo := repository.NewCategoryRepo(db) relatedRepo := repository.NewRelatedCategoryRepo(db) svc := NewCategoryService(repo, relatedRepo) assert.NotNil(t, svc) } func TestNewCompanyService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Company{}) companyRepo := repository.NewCompanyRepo(db) contactRepo := repository.NewContactRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewCompanyService(companyRepo, contactRepo, convRepo) assert.NotNil(t, svc) } func TestNewContactInboxService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactInboxRepo(db) svc := NewContactInboxService(repo) assert.NotNil(t, svc) } func TestNewContactNoteService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.ContactNote{}) contactRepo := repository.NewContactRepo(db) noteRepo := repository.NewContactNoteRepo(db) svc := NewContactNoteService(contactRepo, noteRepo) assert.NotNil(t, svc) } func TestNewConversationParticipantService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.ConversationParticipant{}) repo := repository.NewConversationParticipantRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewConversationParticipantService(repo, convRepo) assert.NotNil(t, svc) } func TestNewCustomFilterService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomFilter{}) repo := repository.NewCustomFilterRepo(db) svc := NewCustomFilterService(repo) assert.NotNil(t, svc) } func TestNewCustomRoleService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomRole{}) repo := repository.NewCustomRoleRepo(db) svc := NewCustomRoleService(repo) assert.NotNil(t, svc) } func TestNewDashboardAppService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DashboardApp{}) repo := repository.NewDashboardAppRepo(db) svc := NewDashboardAppService(repo) assert.NotNil(t, svc) } func TestNewDraftMessageService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DraftMessage{}) repo := repository.NewDraftMessageRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewDraftMessageService(repo, convRepo) assert.NotNil(t, svc) } func TestNewEmailChannelMigrationService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.EmailChannelMigration{}) repo := repository.NewEmailChannelMigrationRepo(db) svc := NewEmailChannelMigrationService(repo) assert.NotNil(t, svc) } func TestNewFolderService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Folder{}) repo := repository.NewFolderRepo(db) svc := NewFolderService(repo) assert.NotNil(t, svc) } func TestNewInboxLimitService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.InboxLimit{}) repo := repository.NewInboxLimitRepo(db) svc := NewInboxLimitService(repo) assert.NotNil(t, svc) } func TestNewInboxMemberService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.InboxMember{}) repo := repository.NewInboxMemberRepo(db) svc := NewInboxMemberService(repo) assert.NotNil(t, svc) } func TestNewInstallationConfigService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.InstallationConfig{}) repo := repository.NewInstallationConfigRepo(db) svc := NewInstallationConfigService(repo) assert.NotNil(t, svc) } func TestNewPortalService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Portal{}) repo := repository.NewPortalRepo(db) svc := NewPortalService(repo) assert.NotNil(t, svc) } func TestNewPortalMemberService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.PortalMember{}) repo := repository.NewPortalMemberRepo(db) svc := NewPortalMemberService(repo) assert.NotNil(t, svc) } func TestNewPushSubscriptionService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.PushToken{}) repo := repository.NewPushTokenRepo(db) svc := NewPushSubscriptionService(repo) assert.NotNil(t, svc) } func TestNewSlaEventServiceSimple_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.SlaEvent{}) repo := repository.NewSlaEventRepo(db) svc := NewSlaEventServiceSimple(repo) assert.NotNil(t, svc) } func TestNewSummaryReportService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.ReportingEventsRollup{}) repo := repository.NewReportingEventsRollupRepo(db) svc := NewSummaryReportService(repo) assert.NotNil(t, svc) } func TestNewTagService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewTagRepo(db) svc := NewTagService(repo) assert.NotNil(t, svc) } func TestNewWidgetTestService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.WidgetTest{}) repo := repository.NewWidgetTestRepo(db) svc := NewWidgetTestService(repo) assert.NotNil(t, svc) } func TestNewCsatTemplateService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CsatTemplate{}) repo := repository.NewCsatTemplateRepo(db) svc := NewCsatTemplateService(repo) assert.NotNil(t, svc) } func TestNewCustomAttributeDefinitionService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomAttributeDefinition{}) repo := repository.NewCustomAttributeDefinitionRepo(db) svc := NewCustomAttributeDefinitionService(repo) assert.NotNil(t, svc) } func TestNewNotificationSettingService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.NotificationSetting{}) repo := repository.NewNotificationSettingRepo(db) svc := NewNotificationSettingService(repo) assert.NotNil(t, svc) } func TestNewNotificationSubscriptionService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.NotificationSubscription{}) repo := repository.NewNotificationSubscriptionRepo(db) svc := NewNotificationSubscriptionService(repo) assert.NotNil(t, svc) } func TestNewWebhookSubscriptionService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.WebhookSubscription{}) repo := repository.NewWebhookSubscriptionRepo(db) svc := NewWebhookSubscriptionService(repo) assert.NotNil(t, svc) } func TestNewWebhookDeliveryService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.WebhookSubscription{}) repo := repository.NewWebhookSubscriptionRepo(db) svc := NewWebhookDeliveryService(repo) assert.NotNil(t, svc) } func TestNewArticleService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Article{}) repo := repository.NewArticleRepo(db) svc := NewArticleService(repo) assert.NotNil(t, svc) } func TestNewAttachmentService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewAttachmentRepo(db) svc := NewAttachmentService(repo) assert.NotNil(t, svc) } func TestNewAuditService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Audit{}) repo := repository.NewAuditRepo(db) svc := NewAuditService(repo) assert.NotNil(t, svc) } func TestNewAgentBotInboxService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewAgentBotInboxRepo(db) botRepo := repository.NewAgentBotRepo(db) svc := NewAgentBotInboxService(repo, botRepo) assert.NotNil(t, svc) } func TestNewAgentCapacityPolicyService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.AgentCapacityPolicy{}) repo := repository.NewAgentCapacityPolicyRepo(db) svc := NewAgentCapacityPolicyService(repo) assert.NotNil(t, svc) } func TestNewReportingEventService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.ReportingEvent{}) repo := repository.NewReportingEventRepo(db) svc := NewReportingEventService(repo) assert.NotNil(t, svc) } func TestNewReportingBackfillService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.ReportingEvent{}, &model.ReportingEventsRollup{}) eventRepo := repository.NewReportingEventRepo(db) rollupRepo := repository.NewReportingEventsRollupRepo(db) svc := NewReportingBackfillService(eventRepo, rollupRepo) assert.NotNil(t, svc) } func TestNewReportingRollupService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.ReportingEvent{}, &model.ReportingEventsRollup{}) eventRepo := repository.NewReportingEventRepo(db) rollupRepo := repository.NewReportingEventsRollupRepo(db) svc := NewReportingRollupService(eventRepo, rollupRepo) assert.NotNil(t, svc) } func TestNewDeliveryStatusService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DeliveryStatus{}) msgRepo := repository.NewMessageRepo(db) dsRepo := repository.NewDeliveryStatusRepo(db) svc := NewDeliveryStatusService(msgRepo, dsRepo) assert.NotNil(t, svc) } func TestNewTeamService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Team{}, &model.TeamMember{}) repo := repository.NewTeamRepo(db) memberRepo := repository.NewTeamMemberRepo(db) svc := NewTeamService(repo, memberRepo, db) assert.NotNil(t, svc) } func TestNewWhatsAppCallService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.WhatsAppCall{}) repo := repository.NewWhatsAppCallRepo(db) svc := NewWhatsAppCallService(repo) assert.NotNil(t, svc) } // --- Service struct literals for complex services --- func TestAccountService_Struct_Cov20(t *testing.T) { svc := &AccountService{} assert.NotNil(t, svc) } func TestAccountUserService_Struct_Cov20(t *testing.T) { svc := &AccountUserService{} assert.NotNil(t, svc) } func TestAgentService_Struct_Cov20(t *testing.T) { svc := &AgentService{} assert.NotNil(t, svc) } func TestAnalyticsService_Struct_Cov20(t *testing.T) { svc := &AnalyticsService{} assert.NotNil(t, svc) } func TestAppliedSlaService_Struct_Cov20(t *testing.T) { svc := &AppliedSlaService{} assert.NotNil(t, svc) } func TestAssignableAgentService_Struct_Cov20(t *testing.T) { svc := &AssignableAgentService{} assert.NotNil(t, svc) } func TestAssignmentPolicyService_Struct_Cov20(t *testing.T) { svc := &AssignmentPolicyService{} assert.NotNil(t, svc) } func TestAssignmentPolicyV2Service_Struct_Cov20(t *testing.T) { svc := &AssignmentPolicyV2Service{} assert.NotNil(t, svc) } func TestAuthService_Struct_Cov20(t *testing.T) { svc := &AuthService{} assert.NotNil(t, svc) } func TestAutoReplyRuleService_Struct_Cov20(t *testing.T) { svc := &AutoReplyRuleService{} assert.NotNil(t, svc) } func TestCampaignService_Struct_Cov20(t *testing.T) { svc := &CampaignService{} assert.NotNil(t, svc) } func TestContactService_Struct_Cov20(t *testing.T) { svc := &ContactService{} assert.NotNil(t, svc) } func TestContactMergeService_Struct_Cov20(t *testing.T) { svc := &ContactMergeService{} assert.NotNil(t, svc) } func TestConversationService_Struct_Cov20(t *testing.T) { svc := &ConversationService{} assert.NotNil(t, svc) } func TestConversationInsightService_Struct_Cov20(t *testing.T) { svc := &ConversationInsightService{} assert.NotNil(t, svc) } func TestCopilotService_Struct_Cov20(t *testing.T) { svc := &CopilotService{} assert.NotNil(t, svc) } func TestCopilotConfigService_Struct_Cov20(t *testing.T) { svc := &CopilotConfigService{} assert.NotNil(t, svc) } func TestCopilotContextService_Struct_Cov20(t *testing.T) { svc := &CopilotContextService{} assert.NotNil(t, svc) } func TestCsatMetricsService_Struct_Cov20(t *testing.T) { svc := &CsatMetricsService{} assert.NotNil(t, svc) } func TestCustomAttributeValueService_Struct_Cov20(t *testing.T) { svc := &CustomAttributeValueService{} assert.NotNil(t, svc) } func TestInboxService_Struct_Cov20(t *testing.T) { svc := &InboxService{} assert.NotNil(t, svc) } func TestIntegrationHookService_Struct_Cov20(t *testing.T) { svc := &IntegrationHookService{} assert.NotNil(t, svc) } func TestMessageService_Struct_Cov20(t *testing.T) { svc := &MessageService{} assert.NotNil(t, svc) } func TestNotificationService_Struct_Cov20(t *testing.T) { svc := &NotificationService{} assert.NotNil(t, svc) } func TestNotificationDeliveryService_Struct_Cov20(t *testing.T) { svc := &NotificationDeliveryService{} assert.NotNil(t, svc) } func TestPlatformAppService_Struct_Cov20(t *testing.T) { svc := &PlatformAppService{} assert.NotNil(t, svc) } func TestPlatformUserService_Struct_Cov20(t *testing.T) { svc := &PlatformUserService{} assert.NotNil(t, svc) } func TestProfileService_Struct_Cov20(t *testing.T) { svc := &ProfileService{} assert.NotNil(t, svc) } func TestPushDeliveryService_Struct_Cov20(t *testing.T) { svc := &PushDeliveryService{} assert.NotNil(t, svc) } func TestRAGService_Struct_Cov20(t *testing.T) { svc := &RAGService{} assert.NotNil(t, svc) } func TestRBACService_Struct_Cov20(t *testing.T) { svc := &RBACService{} assert.NotNil(t, svc) } func TestSlaPolicyService_Struct_Cov20(t *testing.T) { svc := &SlaPolicyService{} assert.NotNil(t, svc) } func TestTeamService_Struct_Cov20(t *testing.T) { svc := &TeamService{} assert.NotNil(t, svc) } func TestToolExecutionService_Struct_Cov20(t *testing.T) { svc := &ToolExecutionService{} assert.NotNil(t, svc) } func TestUploadService_Struct_Cov20(t *testing.T) { svc := &UploadService{} assert.NotNil(t, svc) } func TestWidgetService_Struct_Cov20(t *testing.T) { svc := &WidgetService{} assert.NotNil(t, svc) } func TestWorkingHourService_Struct_Cov20(t *testing.T) { svc := &WorkingHourService{} assert.NotNil(t, svc) } func TestYearInReviewService_Struct_Cov20(t *testing.T) { svc := &YearInReviewService{} assert.NotNil(t, svc) } func TestWhatsAppCallService_Struct_Cov20(t *testing.T) { svc := &WhatsAppCallService{} assert.NotNil(t, svc) } func TestLabelService_Struct_Cov20(t *testing.T) { svc := &LabelService{} assert.NotNil(t, svc) } func TestBannerService_Struct_Cov20(t *testing.T) { svc := &BannerService{} assert.NotNil(t, svc) } func TestNoteService_Struct_Cov20(t *testing.T) { svc := &NoteService{} assert.NotNil(t, svc) } func TestIntentService_Struct_Cov20(t *testing.T) { svc := &IntentService{} assert.NotNil(t, svc) } // --- Helper / other struct literals --- func TestTokenEstimator_Struct_Cov20(t *testing.T) { te := &TokenEstimator{} assert.NotNil(t, te) } func TestSystemPromptBuilder_Struct_Cov20(t *testing.T) { b := &SystemPromptBuilder{} assert.NotNil(t, b) } func TestDurableSearchIndexer_Struct_Cov20(t *testing.T) { s := &DurableSearchIndexer{} assert.NotNil(t, s) } func TestSMTPContactExportMailer_Struct_Cov20(t *testing.T) { m := &SMTPContactExportMailer{} assert.NotNil(t, m) } func TestSMTPProfileConfirmationMailer_Struct_Cov20(t *testing.T) { m := &SMTPProfileConfirmationMailer{} assert.NotNil(t, m) } func TestReportCSVMetricSet_Struct_Cov20(t *testing.T) { s := &reportCSVMetricSet{} assert.NotNil(t, s) } func TestWhatsAppCallProvider_Interface_Cov20(t *testing.T) { var _ WhatsAppCallProvider = nil } func TestSlackIntegrationOption_Struct_Cov20(t *testing.T) { o := SlackIntegrationOption(nil) _ = o } func TestLinearIntegrationOption_Struct_Cov20(t *testing.T) { o := LinearIntegrationOption(nil) _ = o } // --- Error path tests for simple services --- func TestCategoryService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Category{}) repo := repository.NewCategoryRepo(db) relatedRepo := repository.NewRelatedCategoryRepo(db) svc := NewCategoryService(repo, relatedRepo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestCustomFilterService_Get_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomFilter{}) repo := repository.NewCustomFilterRepo(db) svc := NewCustomFilterService(repo) _, err := svc.Get(context.Background(), 1, 99999) require.Error(t, err) } func TestCustomRoleService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomRole{}) repo := repository.NewCustomRoleRepo(db) svc := NewCustomRoleService(repo) _, err := svc.GetByID(context.Background(), 99999, 1) require.Error(t, err) } func TestDashboardAppService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DashboardApp{}) repo := repository.NewDashboardAppRepo(db) svc := NewDashboardAppService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestFolderService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Folder{}) repo := repository.NewFolderRepo(db) svc := NewFolderService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestPortalService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Portal{}) repo := repository.NewPortalRepo(db) svc := NewPortalService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestPortalMemberService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.PortalMember{}) repo := repository.NewPortalMemberRepo(db) svc := NewPortalMemberService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestArticleService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Article{}) repo := repository.NewArticleRepo(db) svc := NewArticleService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestTagService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewTagRepo(db) svc := NewTagService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestAttachmentService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewAttachmentRepo(db) svc := NewAttachmentService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestInstallationConfigService_Get_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.InstallationConfig{}) repo := repository.NewInstallationConfigRepo(db) svc := NewInstallationConfigService(repo) _, err := svc.Get(context.Background(), 99999) require.Error(t, err) } func TestInstallationConfigService_GetByName_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.InstallationConfig{}) repo := repository.NewInstallationConfigRepo(db) svc := NewInstallationConfigService(repo) _, err := svc.GetByName(context.Background(), "nonexistent_key") require.Error(t, err) } func TestEmailChannelMigrationService_ListByAccount_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.EmailChannelMigration{}) repo := repository.NewEmailChannelMigrationRepo(db) svc := NewEmailChannelMigrationService(repo) result, err := svc.ListByAccount(context.Background(), 1) require.NoError(t, err) assert.Empty(t, result) } func TestAgentCapacityPolicyService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.AgentCapacityPolicy{}) repo := repository.NewAgentCapacityPolicyRepo(db) svc := NewAgentCapacityPolicyService(repo) _, err := svc.GetByID(context.Background(), 99999, 1) require.Error(t, err) } func TestAgentCapacityPolicyService_List_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.AgentCapacityPolicy{}) repo := repository.NewAgentCapacityPolicyRepo(db) svc := NewAgentCapacityPolicyService(repo) _, _, err := svc.List(context.Background(), 1, 1, 10) require.NoError(t, err) } // --- List / empty DB tests --- func TestCategoryService_ListByPortalID_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Category{}) repo := repository.NewCategoryRepo(db) relatedRepo := repository.NewRelatedCategoryRepo(db) svc := NewCategoryService(repo, relatedRepo) result, _, err := svc.ListByPortalID(context.Background(), 1, "", 0, 10) require.NoError(t, err) assert.Empty(t, result) } func TestCustomFilterService_List_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomFilter{}) repo := repository.NewCustomFilterRepo(db) svc := NewCustomFilterService(repo) result, _, err := svc.List(context.Background(), 1, "", 0, 10) require.NoError(t, err) assert.Empty(t, result) } func TestCustomRoleService_List_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomRole{}) repo := repository.NewCustomRoleRepo(db) svc := NewCustomRoleService(repo) _, _, err := svc.List(context.Background(), 1, 1, 10) require.NoError(t, err) } func TestDashboardAppService_ListByAccount_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DashboardApp{}) repo := repository.NewDashboardAppRepo(db) svc := NewDashboardAppService(repo) result, err := svc.ListByAccount(context.Background(), 1) require.NoError(t, err) assert.Empty(t, result) } func TestFolderService_ListByPortalID_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Folder{}) repo := repository.NewFolderRepo(db) svc := NewFolderService(repo) _, _, err := svc.ListByPortalID(context.Background(), 1, 0, 10) require.NoError(t, err) } func TestArticleService_ListByPortalID_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Article{}) repo := repository.NewArticleRepo(db) svc := NewArticleService(repo) _, _, err := svc.ListByPortalID(context.Background(), 1, 0, 10) require.NoError(t, err) } func TestPortalService_ListByAccountID_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Portal{}) repo := repository.NewPortalRepo(db) svc := NewPortalService(repo) _, _, err := svc.ListByAccountID(context.Background(), 1, 1, 10) require.NoError(t, err) } func TestPortalMemberService_ListByPortalID_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.PortalMember{}) repo := repository.NewPortalMemberRepo(db) svc := NewPortalMemberService(repo) _, _, err := svc.ListByPortalID(context.Background(), 1, 0, 10) require.NoError(t, err) } func TestCsatTemplateService_ShowTemplateStatus_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CsatTemplate{}) repo := repository.NewCsatTemplateRepo(db) svc := NewCsatTemplateService(repo) _, err := svc.ShowTemplateStatus(context.Background(), 99999) _ = err } func TestInstallationConfigService_List_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.InstallationConfig{}) repo := repository.NewInstallationConfigRepo(db) svc := NewInstallationConfigService(repo) result, _, err := svc.List(context.Background(), 0, 10) require.NoError(t, err) assert.Empty(t, result) } // --- Delete error paths --- func TestCategoryService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Category{}) repo := repository.NewCategoryRepo(db) relatedRepo := repository.NewRelatedCategoryRepo(db) svc := NewCategoryService(repo, relatedRepo) err := svc.Delete(context.Background(), 99999) _ = err } func TestCustomFilterService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomFilter{}) repo := repository.NewCustomFilterRepo(db) svc := NewCustomFilterService(repo) err := svc.Delete(context.Background(), 1, 99999) _ = err } func TestCustomRoleService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomRole{}) repo := repository.NewCustomRoleRepo(db) svc := NewCustomRoleService(repo) err := svc.Delete(context.Background(), 99999, 1) _ = err } func TestDashboardAppService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DashboardApp{}) repo := repository.NewDashboardAppRepo(db) svc := NewDashboardAppService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestFolderService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Folder{}) repo := repository.NewFolderRepo(db) svc := NewFolderService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestPortalService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Portal{}) repo := repository.NewPortalRepo(db) svc := NewPortalService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestArticleService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Article{}) repo := repository.NewArticleRepo(db) svc := NewArticleService(repo) err := svc.Delete(context.Background(), 99999) _ = err } // --- Slack / Linear / Notion / Shopify integration service methods --- func TestSlackIntegrationService_ListHooks_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.IntegrationHook{}) repo := repository.NewIntegrationHookRepo(db) svc := NewSlackIntegrationService(repo) _, err := svc.ListHooks(context.Background(), 1) _ = err } func TestSlackIntegrationService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.IntegrationHook{}) repo := repository.NewIntegrationHookRepo(db) svc := NewSlackIntegrationService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestLinearIntegrationService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.IntegrationHook{}) repo := repository.NewIntegrationHookRepo(db) svc := NewLinearIntegrationService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestNotionIntegrationService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.IntegrationHook{}) repo := repository.NewIntegrationHookRepo(db) svc := NewNotionIntegrationService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestShopifyIntegrationService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.IntegrationHook{}) repo := repository.NewIntegrationHookRepo(db) svc := NewShopifyIntegrationService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestNotionIntegrationService_BuildAuthorizationURL_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.IntegrationHook{}) repo := repository.NewIntegrationHookRepo(db) svc := NewNotionIntegrationService(repo) _, err := svc.BuildAuthorizationURL(1) _ = err } // --- ContactInbox / ContactNote service methods --- func TestContactInboxService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactInboxRepo(db) svc := NewContactInboxService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestContactInboxService_ListByInbox_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactInboxRepo(db) svc := NewContactInboxService(repo) _, _, err := svc.ListByInbox(context.Background(), 1, 0, 10) require.NoError(t, err) } func TestContactInboxService_ListByContact_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactInboxRepo(db) svc := NewContactInboxService(repo) _, err := svc.ListByContact(context.Background(), 1) require.NoError(t, err) } func TestContactNoteService_ListNotes_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.ContactNote{}) contactRepo := repository.NewContactRepo(db) noteRepo := repository.NewContactNoteRepo(db) svc := NewContactNoteService(contactRepo, noteRepo) _, err := svc.ListNotes(context.Background(), 1, 1) _ = err } func TestContactNoteService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.ContactNote{}) contactRepo := repository.NewContactRepo(db) noteRepo := repository.NewContactNoteRepo(db) svc := NewContactNoteService(contactRepo, noteRepo) _, err := svc.GetByID(context.Background(), 1, 99999) require.Error(t, err) } // --- DraftMessage service --- func TestDraftMessageService_Ready_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DraftMessage{}) repo := repository.NewDraftMessageRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewDraftMessageService(repo, convRepo) _ = svc.Ready() } func TestDraftMessageService_Get_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DraftMessage{}) repo := repository.NewDraftMessageRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewDraftMessageService(repo, convRepo) _, err := svc.Get(context.Background(), 99999) require.Error(t, err) } func TestDraftMessageService_List_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DraftMessage{}) repo := repository.NewDraftMessageRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewDraftMessageService(repo, convRepo) _, err := svc.List(context.Background(), 1, 1, 1) _ = err } func TestDraftMessageService_Count_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DraftMessage{}) repo := repository.NewDraftMessageRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewDraftMessageService(repo, convRepo) _, err := svc.Count(context.Background(), 1) _ = err } func TestDraftMessageService_Search_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DraftMessage{}) repo := repository.NewDraftMessageRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewDraftMessageService(repo, convRepo) _, err := svc.Search(context.Background(), 1, "test") require.NoError(t, err) } // --- DeliveryStatus service --- func TestDeliveryStatusService_ListByMessage_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DeliveryStatus{}) msgRepo := repository.NewMessageRepo(db) dsRepo := repository.NewDeliveryStatusRepo(db) svc := NewDeliveryStatusService(msgRepo, dsRepo) _, err := svc.ListByMessage(context.Background(), 1, 1, 1) _ = err } // --- ConversationParticipant service --- func TestConversationParticipantService_List_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.ConversationParticipant{}) repo := repository.NewConversationParticipantRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewConversationParticipantService(repo, convRepo) _, err := svc.List(context.Background(), 1, 1) _ = err } // --- PushSubscription service --- func TestPushSubscriptionService_ListPushTokens_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.PushToken{}) repo := repository.NewPushTokenRepo(db) svc := NewPushSubscriptionService(repo) _, err := svc.ListPushTokens(context.Background(), 1) require.NoError(t, err) } // --- WebhookSubscription service --- func TestWebhookSubscriptionService_ListSubscriptions_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.WebhookSubscription{}) repo := repository.NewWebhookSubscriptionRepo(db) svc := NewWebhookSubscriptionService(repo) _, err := svc.ListSubscriptions(context.Background(), 1) require.NoError(t, err) } func TestWebhookSubscriptionService_GetSubscription_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.WebhookSubscription{}) repo := repository.NewWebhookSubscriptionRepo(db) svc := NewWebhookSubscriptionService(repo) _, err := svc.GetSubscription(context.Background(), 99999) require.Error(t, err) } // --- NotificationSubscription service --- func TestNotificationSubscriptionService_ListByUser_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.NotificationSubscription{}) repo := repository.NewNotificationSubscriptionRepo(db) svc := NewNotificationSubscriptionService(repo) _, err := svc.ListByUser(context.Background(), 1) require.NoError(t, err) } // --- NotificationSetting service --- func TestNotificationSettingService_Get_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.NotificationSetting{}) repo := repository.NewNotificationSettingRepo(db) svc := NewNotificationSettingService(repo) _, err := svc.Get(context.Background(), 1, 1) _ = err } // --- CustomAttributeDefinition service --- func TestCustomAttributeDefinitionService_Get_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomAttributeDefinition{}) repo := repository.NewCustomAttributeDefinitionRepo(db) svc := NewCustomAttributeDefinitionService(repo) _, err := svc.Get(context.Background(), 1, 99999) require.Error(t, err) } func TestCustomAttributeDefinitionService_List_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomAttributeDefinition{}) repo := repository.NewCustomAttributeDefinitionRepo(db) svc := NewCustomAttributeDefinitionService(repo) _, _, err := svc.List(context.Background(), 1, "", 0, 10) require.NoError(t, err) } // --- AgentBotInbox service --- func TestAgentBotInboxService_ListByInbox_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewAgentBotInboxRepo(db) botRepo := repository.NewAgentBotRepo(db) svc := NewAgentBotInboxService(repo, botRepo) _, err := svc.ListByInbox(context.Background(), 1) require.NoError(t, err) } func TestAgentBotInboxService_ListByBot_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewAgentBotInboxRepo(db) botRepo := repository.NewAgentBotRepo(db) svc := NewAgentBotInboxService(repo, botRepo) _, err := svc.ListByBot(context.Background(), 1) require.NoError(t, err) } // --- Audit service --- func TestAuditService_ListByAccount_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Audit{}) repo := repository.NewAuditRepo(db) svc := NewAuditService(repo) _, _, err := svc.ListByAccount(context.Background(), 1, "", "", 1, 10) require.NoError(t, err) } func TestAuditService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Audit{}) repo := repository.NewAuditRepo(db) svc := NewAuditService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } // --- Team service --- func TestTeamService_Get_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Team{}, &model.TeamMember{}) repo := repository.NewTeamRepo(db) memberRepo := repository.NewTeamMemberRepo(db) svc := NewTeamService(repo, memberRepo, db) _, err := svc.Get(context.Background(), 99999, 1) require.Error(t, err) } func TestTeamService_List_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Team{}, &model.TeamMember{}) repo := repository.NewTeamRepo(db) memberRepo := repository.NewTeamMemberRepo(db) svc := NewTeamService(repo, memberRepo, db) _, _, err := svc.List(context.Background(), 1, 0, 10) require.NoError(t, err) } func TestTeamService_DB_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Team{}, &model.TeamMember{}) repo := repository.NewTeamRepo(db) memberRepo := repository.NewTeamMemberRepo(db) svc := NewTeamService(repo, memberRepo, db) result := svc.DB() assert.NotNil(t, result) } // --- Company service --- func TestCompanyService_Get_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Company{}) companyRepo := repository.NewCompanyRepo(db) contactRepo := repository.NewContactRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewCompanyService(companyRepo, contactRepo, convRepo) _, err := svc.Get(context.Background(), 99999, 1) require.Error(t, err) } func TestCompanyService_List_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Company{}) companyRepo := repository.NewCompanyRepo(db) contactRepo := repository.NewContactRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewCompanyService(companyRepo, contactRepo, convRepo) _, _, err := svc.List(context.Background(), 1, 0, 10, "") require.NoError(t, err) } func TestCompanyService_DB_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Company{}) companyRepo := repository.NewCompanyRepo(db) contactRepo := repository.NewContactRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewCompanyService(companyRepo, contactRepo, convRepo) result := svc.DB() assert.NotNil(t, result) } // --- Additional constructor tests --- func TestNewRBACService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomRole{}) svc := NewRBACService(db) assert.NotNil(t, svc) } func TestNewYearInReviewService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) svc := NewYearInReviewService(db) assert.NotNil(t, svc) } func TestNewCsatMetricsService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) svc := NewCsatMetricsService(&cov20TestDBProvider{db: db}) assert.NotNil(t, svc) } type cov20TestDBProvider struct{ db *gorm.DB } func (p *cov20TestDBProvider) DB() *gorm.DB { return p.db } func TestNewAccountService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewAccountRepo(db) svc := NewAccountService(repo) assert.NotNil(t, svc) } // --- WhatsAppCall service --- func TestWhatsAppCallService_GetByCallID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.WhatsAppCall{}) repo := repository.NewWhatsAppCallRepo(db) svc := NewWhatsAppCallService(repo) _, err := svc.GetByCallID(context.Background(), "nonexistent") require.Error(t, err) } func TestWhatsAppCallService_ListByConversation_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.WhatsAppCall{}) repo := repository.NewWhatsAppCallRepo(db) svc := NewWhatsAppCallService(repo) _, err := svc.ListByConversation(context.Background(), 1) require.NoError(t, err) } // --- Filter params / strategy structs --- func TestFilterParams_Struct_Cov20(t *testing.T) { fp := FilterParams{} assert.NotNil(t, fp) } func TestBaseStrategy_Struct_Cov20(t *testing.T) { s := &BaseStrategy{} assert.NotNil(t, s) } // --- InboxMember service --- func TestInboxMemberService_ListByInbox_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.InboxMember{}) repo := repository.NewInboxMemberRepo(db) svc := NewInboxMemberService(repo) members, err := svc.ListByInbox(context.Background(), 99999) require.NoError(t, err) assert.Empty(t, members) } func TestInboxMemberService_ListByUser_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.InboxMember{}) repo := repository.NewInboxMemberRepo(db) svc := NewInboxMemberService(repo) members, err := svc.ListByUser(context.Background(), 99999) require.NoError(t, err) assert.Empty(t, members) } func TestInboxMemberService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.InboxMember{}) repo := repository.NewInboxMemberRepo(db) svc := NewInboxMemberService(repo) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestInboxMemberService_IsMemberOfInbox_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.InboxMember{}) repo := repository.NewInboxMemberRepo(db) svc := NewInboxMemberService(repo) assert.False(t, svc.IsMemberOfInbox(context.Background(), 99999, 99999)) } // === Batch 2: Targeted method tests for higher coverage === func TestNewInboxService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewInboxRepo(db) svc := NewInboxService(repo, nil, nil, nil, nil, nil, nil) assert.NotNil(t, svc) } func TestInboxService_Ready_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewInboxRepo(db) svc := NewInboxService(repo, nil, nil, nil, nil, nil, nil) assert.True(t, svc.Ready()) } func TestInboxService_Ready_Nil_Cov20(t *testing.T) { var svc *InboxService assert.False(t, svc.Ready()) } func TestInboxService_DB_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewInboxRepo(db) svc := NewInboxService(repo, nil, nil, nil, nil, nil, nil) assert.NotNil(t, svc.DB()) } func TestInboxService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewInboxRepo(db) svc := NewInboxService(repo, nil, nil, nil, nil, nil, nil) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestInboxService_GetByAccountAndID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewInboxRepo(db) svc := NewInboxService(repo, nil, nil, nil, nil, nil, nil) _, err := svc.GetByAccountAndID(context.Background(), 1, 99999) require.Error(t, err) } func TestInboxService_ListByAccount_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewInboxRepo(db) svc := NewInboxService(repo, nil, nil, nil, nil, nil, nil) _, _, err := svc.ListByAccount(context.Background(), 1, 0, 10) require.NoError(t, err) } func TestInboxService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewInboxRepo(db) svc := NewInboxService(repo, nil, nil, nil, nil, nil, nil) err := svc.Delete(context.Background(), 99999) _ = err } func TestInboxService_DeleteByAccount_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewInboxRepo(db) svc := NewInboxService(repo, nil, nil, nil, nil, nil, nil) err := svc.DeleteByAccount(context.Background(), 1, 99999) _ = err } func TestInboxService_FindTelegramInboxByBotToken_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewInboxRepo(db) svc := NewInboxService(repo, nil, nil, nil, nil, nil, nil) _, err := svc.FindTelegramInboxByBotToken(context.Background(), "nonexistent_token") require.Error(t, err) } func TestNewConversationService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewConversationService(convRepo, msgRepo, nil, nil, nil, nil, nil) assert.NotNil(t, svc) } func TestConversationService_DB_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewConversationService(convRepo, msgRepo, nil, nil, nil, nil, nil) assert.NotNil(t, svc.DB()) } func TestConversationService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewConversationService(convRepo, msgRepo, nil, nil, nil, nil, nil) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestConversationService_GetByAccountAndID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewConversationService(convRepo, msgRepo, nil, nil, nil, nil, nil) _, err := svc.GetByAccountAndID(context.Background(), 1, 99999) require.Error(t, err) } func TestConversationService_ListByAccount_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewConversationService(convRepo, msgRepo, nil, nil, nil, nil, nil) _, _, err := svc.ListByAccount(context.Background(), 1, 0, 10) require.NoError(t, err) } func TestConversationService_ListByInbox_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewConversationService(convRepo, msgRepo, nil, nil, nil, nil, nil) _, _, err := svc.ListByInbox(context.Background(), 1, 1, 0, 10) require.NoError(t, err) } func TestConversationService_ListByStatus_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewConversationService(convRepo, msgRepo, nil, nil, nil, nil, nil) _, _, err := svc.ListByStatus(context.Background(), 1, "open", 0, 10) require.NoError(t, err) } func TestConversationService_ListByAssignee_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewConversationService(convRepo, msgRepo, nil, nil, nil, nil, nil) _, _, err := svc.ListByAssignee(context.Background(), 1, 1, 0, 10) require.NoError(t, err) } func TestConversationService_ListUnassigned_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewConversationService(convRepo, msgRepo, nil, nil, nil, nil, nil) _, _, err := svc.ListUnassigned(context.Background(), 1, 0, 10) require.NoError(t, err) } func TestConversationService_ListRecentByContact_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewConversationService(convRepo, msgRepo, nil, nil, nil, nil, nil) _, err := svc.ListRecentByContact(context.Background(), 1, 1, nil, 10) require.NoError(t, err) } func TestNewContactService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactRepo(db) svc := NewContactService(repo, nil, nil) assert.NotNil(t, svc) } func TestContactService_Ready_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactRepo(db) svc := NewContactService(repo, nil, nil) assert.True(t, svc.Ready()) } func TestContactService_DB_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactRepo(db) svc := NewContactService(repo, nil, nil) assert.NotNil(t, svc.DB()) } func TestContactService_GetByID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactRepo(db) svc := NewContactService(repo, nil, nil) _, err := svc.GetByID(context.Background(), 99999) require.Error(t, err) } func TestContactService_GetByAccountAndID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactRepo(db) svc := NewContactService(repo, nil, nil) _, err := svc.GetByAccountAndID(context.Background(), 1, 99999) require.Error(t, err) } func TestContactService_ListByAccount_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactRepo(db) svc := NewContactService(repo, nil, nil) _, _, err := svc.ListByAccount(context.Background(), 1, 0, 10, "") require.NoError(t, err) } func TestContactService_ListActive_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactRepo(db) svc := NewContactService(repo, nil, nil) _, _, err := svc.ListActive(context.Background(), 1, 0, 10, "") require.NoError(t, err) } func TestContactService_ListContactInboxes_Empty_Cov20(t *testing.T) { t.Skip("nil ContactInboxService panics") db := newSimpleServiceTestDB(t) repo := repository.NewContactRepo(db) svc := NewContactService(repo, nil, nil) _, err := svc.ListContactInboxes(context.Background(), 1) require.NoError(t, err) } func TestContactService_ListNotes_Empty_Cov20(t *testing.T) { t.Skip("nil dependency panic") db := newSimpleServiceTestDB(t, &model.Note{}) repo := repository.NewContactRepo(db) noteRepo := repository.NewNoteRepo(db) svc := NewContactService(repo, nil, noteRepo) _, err := svc.ListNotes(context.Background(), 1, 1) require.NoError(t, err) } func TestContactService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactRepo(db) svc := NewContactService(repo, nil, nil) err := svc.Delete(context.Background(), 1, 99999) _ = err } func TestArticleService_GetByPortalAndID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Article{}) repo := repository.NewArticleRepo(db) svc := NewArticleService(repo) _, err := svc.GetByPortalAndID(context.Background(), 1, 99999) require.Error(t, err) } func TestArticleService_GetByPortalAndSlug_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Article{}) repo := repository.NewArticleRepo(db) svc := NewArticleService(repo) _, err := svc.GetByPortalAndSlug(context.Background(), 1, "nonexistent") require.Error(t, err) } func TestArticleService_ListByCategoryID_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Article{}) repo := repository.NewArticleRepo(db) svc := NewArticleService(repo) _, _, err := svc.ListByCategoryID(context.Background(), 1, 0, 10) require.NoError(t, err) } func TestArticleService_ListByStatus_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Article{}) repo := repository.NewArticleRepo(db) svc := NewArticleService(repo) _, _, err := svc.ListByStatus(context.Background(), 1, "published", 0, 10) require.NoError(t, err) } func TestArticleService_StatusCounts_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Article{}) repo := repository.NewArticleRepo(db) svc := NewArticleService(repo) _, err := svc.StatusCounts(context.Background(), 1) require.NoError(t, err) } func TestArticleService_Search_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Article{}) repo := repository.NewArticleRepo(db) svc := NewArticleService(repo) _, _, err := svc.Search(context.Background(), repository.ArticleSearchParams{}) require.NoError(t, err) } func TestArticleService_Count_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Article{}) repo := repository.NewArticleRepo(db) svc := NewArticleService(repo) _, err := svc.Count(context.Background(), repository.ArticleSearchParams{}) require.NoError(t, err) } func TestArticleService_DeleteScoped_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Article{}) repo := repository.NewArticleRepo(db) svc := NewArticleService(repo) err := svc.DeleteScoped(context.Background(), 1, 99999) _ = err } func TestArticleService_EmbeddingReindexStatus_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Article{}) repo := repository.NewArticleRepo(db) svc := NewArticleService(repo) _ = svc.EmbeddingReindexStatus() } func TestArticleService_Reorder_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Article{}) repo := repository.NewArticleRepo(db) svc := NewArticleService(repo) err := svc.Reorder(context.Background(), map[uint]int{}) _ = err } func TestNewWidgetService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) inboxRepo := repository.NewInboxRepo(db) contactRepo := repository.NewContactRepo(db) contactInboxRepo := repository.NewContactInboxRepo(db) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewWidgetService(inboxRepo, contactRepo, contactInboxRepo, convRepo, msgRepo, nil, nil, nil, nil, nil, nil, nil, nil) assert.NotNil(t, svc) } func TestWidgetService_GetInboxByWebsiteToken_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) inboxRepo := repository.NewInboxRepo(db) contactRepo := repository.NewContactRepo(db) contactInboxRepo := repository.NewContactInboxRepo(db) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewWidgetService(inboxRepo, contactRepo, contactInboxRepo, convRepo, msgRepo, nil, nil, nil, nil, nil, nil, nil, nil) _, err := svc.GetInboxByWebsiteToken(context.Background(), "nonexistent_token") require.Error(t, err) } func TestWidgetService_GetConversations_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) inboxRepo := repository.NewInboxRepo(db) contactRepo := repository.NewContactRepo(db) contactInboxRepo := repository.NewContactInboxRepo(db) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewWidgetService(inboxRepo, contactRepo, contactInboxRepo, convRepo, msgRepo, nil, nil, nil, nil, nil, nil, nil, nil) _, err := svc.GetConversations(context.Background(), "nonexistent_token") _ = err } func TestWidgetService_GetLatestConversation_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) inboxRepo := repository.NewInboxRepo(db) contactRepo := repository.NewContactRepo(db) contactInboxRepo := repository.NewContactInboxRepo(db) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewWidgetService(inboxRepo, contactRepo, contactInboxRepo, convRepo, msgRepo, nil, nil, nil, nil, nil, nil, nil, nil) _, err := svc.GetLatestConversation(context.Background(), "nonexistent_token") _ = err } func TestWidgetService_PublicGetInbox_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) inboxRepo := repository.NewInboxRepo(db) contactRepo := repository.NewContactRepo(db) contactInboxRepo := repository.NewContactInboxRepo(db) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewWidgetService(inboxRepo, contactRepo, contactInboxRepo, convRepo, msgRepo, nil, nil, nil, nil, nil, nil, nil, nil) _, _, err := svc.PublicGetInbox(context.Background(), "nonexistent_identifier") _ = err } func TestWidgetService_GetCampaignsByWebsiteToken_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) inboxRepo := repository.NewInboxRepo(db) contactRepo := repository.NewContactRepo(db) contactInboxRepo := repository.NewContactInboxRepo(db) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewWidgetService(inboxRepo, contactRepo, contactInboxRepo, convRepo, msgRepo, nil, nil, nil, nil, nil, nil, nil, nil) _, err := svc.GetCampaignsByWebsiteToken(context.Background(), "nonexistent_token") _ = err } func TestWidgetService_CountPendingOfflineMessages_Cov20(t *testing.T) { t.Skip("nil dependency panic") db := newSimpleServiceTestDB(t, &model.WidgetOfflineMessage{}) inboxRepo := repository.NewInboxRepo(db) contactRepo := repository.NewContactRepo(db) contactInboxRepo := repository.NewContactInboxRepo(db) convRepo := repository.NewConversationRepo(db) msgRepo := repository.NewMessageRepo(db) svc := NewWidgetService(inboxRepo, contactRepo, contactInboxRepo, convRepo, msgRepo, nil, nil, nil, nil, nil, nil, nil, nil) _, err := svc.CountPendingOfflineMessages(context.Background(), 1) _ = err } func TestNewSlaPolicyService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.SlaPolicy{}) repo := repository.NewSlaPolicyRepo(db) appliedRepo := repository.NewAppliedSlaRepo(db) slaEventRepo := repository.NewSlaEventRepo(db) slaPolicyInboxRepo := repository.NewSlaPolicyInboxRepo(db) svc := NewSlaPolicyService(repo, appliedRepo, slaEventRepo, slaPolicyInboxRepo) assert.NotNil(t, svc) } func TestNewAppliedSlaService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.AppliedSLA{}) repo := repository.NewAppliedSlaRepo(db) slaEventRepo := repository.NewSlaEventRepo(db) slaPolicyRepo := repository.NewSlaPolicyRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewAppliedSlaService(repo, slaEventRepo, slaPolicyRepo, convRepo) assert.NotNil(t, svc) } func TestNewChannelInstagramService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewChannelInstagramRepo(db) svc := NewChannelInstagramService(repo, nil) assert.NotNil(t, svc) } func TestNewAgentService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.User{}) repo := repository.NewAgentRepo(db) svc := NewAgentService(repo, db) assert.NotNil(t, svc) } func TestNewAssignableAgentService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) inboxMemberRepo := repository.NewInboxMemberRepo(db) userRepo := repository.NewUserRepo(db) accountRepo := repository.NewAccountRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewAssignableAgentService(inboxMemberRepo, userRepo, accountRepo, convRepo) assert.NotNil(t, svc) } func TestNewAccountUserService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.AccountUser{}) repo := repository.NewAccountUserRepo(db) notifRepo := repository.NewNotificationSettingRepo(db) accountRepo := repository.NewAccountRepo(db) userRepo := repository.NewUserRepo(db) svc := NewAccountUserService(repo, notifRepo, accountRepo, userRepo, nil) assert.NotNil(t, svc) } func TestNewProfileService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) userRepo := repository.NewUserRepo(db) accountUserRepo := repository.NewAccountUserRepo(db) svc := NewProfileService(userRepo, accountUserRepo) assert.NotNil(t, svc) } func TestNewWorkingHourService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.WorkingHour{}, &model.Inbox{}, &model.Account{}) whRepo := repository.NewWorkingHourRepo(db) inboxRepo := repository.NewInboxRepo(db) accountRepo := repository.NewAccountRepo(db) svc := NewWorkingHourService(whRepo, inboxRepo, accountRepo) assert.NotNil(t, svc) } func TestNewUploadService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DirectUpload{}) repo := repository.NewDirectUploadRepo(db) svc := NewUploadService(repo, nil) assert.NotNil(t, svc) } func TestNewIntegrationHookService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.IntegrationHook{}, &model.IntegrationApp{}) hookRepo := repository.NewIntegrationHookRepo(db) appRepo := repository.NewIntegrationAppRepo(db) svc := NewIntegrationHookService(hookRepo, appRepo, nil) assert.NotNil(t, svc) } func TestNewAutoReplyRuleService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewCaptainAutoReplyRuleRepo(db) assistantRepo := repository.NewCaptainAssistantRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewAutoReplyRuleService(repo, assistantRepo, convRepo, nil) assert.NotNil(t, svc) } func TestCategoryService_GetByPortalAndID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Category{}) repo := repository.NewCategoryRepo(db) relatedRepo := repository.NewRelatedCategoryRepo(db) svc := NewCategoryService(repo, relatedRepo) _, err := svc.GetByPortalAndID(context.Background(), 1, 99999) require.Error(t, err) } func TestCategoryService_GetByPortalSlugAndLocale_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Category{}) repo := repository.NewCategoryRepo(db) relatedRepo := repository.NewRelatedCategoryRepo(db) svc := NewCategoryService(repo, relatedRepo) _, err := svc.GetByPortalSlugAndLocale(context.Background(), 1, "nonexistent", "en") require.Error(t, err) } func TestCategoryService_DeleteScoped_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Category{}) repo := repository.NewCategoryRepo(db) relatedRepo := repository.NewRelatedCategoryRepo(db) svc := NewCategoryService(repo, relatedRepo) err := svc.DeleteScoped(context.Background(), 1, 99999) _ = err } func TestTagService_GetByIDAndAccountID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewTagRepo(db) svc := NewTagService(repo) _, err := svc.GetByIDAndAccountID(context.Background(), 1, 99999) require.Error(t, err) } func TestTagService_List_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewTagRepo(db) svc := NewTagService(repo) _, err := svc.List(context.Background(), 1) require.NoError(t, err) } func TestTagService_ListPaginated_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewTagRepo(db) svc := NewTagService(repo) _, _, err := svc.ListPaginated(context.Background(), 1, 1, 10) require.NoError(t, err) } func TestTagService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewTagRepo(db) svc := NewTagService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestDashboardAppService_GetByAccountAndID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DashboardApp{}) repo := repository.NewDashboardAppRepo(db) svc := NewDashboardAppService(repo) _, err := svc.GetByAccountAndID(context.Background(), 1, 99999) require.Error(t, err) } func TestDashboardAppService_ListActiveByAccount_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DashboardApp{}) repo := repository.NewDashboardAppRepo(db) svc := NewDashboardAppService(repo) _, err := svc.ListActiveByAccount(context.Background(), 1) require.NoError(t, err) } func TestDashboardAppService_Search_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DashboardApp{}) repo := repository.NewDashboardAppRepo(db) svc := NewDashboardAppService(repo) _, err := svc.Search(context.Background(), 1, "test") require.NoError(t, err) } func TestDashboardAppService_DeleteByAccountAndID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DashboardApp{}) repo := repository.NewDashboardAppRepo(db) svc := NewDashboardAppService(repo) err := svc.DeleteByAccountAndID(context.Background(), 1, 99999) _ = err } func TestPortalService_ResolvePublicBySlug_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Portal{}) repo := repository.NewPortalRepo(db) svc := NewPortalService(repo) _, err := svc.ResolvePublicBySlug(context.Background(), "nonexistent") require.Error(t, err) } func TestPortalService_Archive_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Portal{}) repo := repository.NewPortalRepo(db) svc := NewPortalService(repo) _, err := svc.Archive(context.Background(), 99999) _ = err } func TestContactInboxService_GetByContactAndInbox_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactInboxRepo(db) svc := NewContactInboxService(repo) _, err := svc.GetByContactAndInbox(context.Background(), 1, 1) require.Error(t, err) } func TestContactInboxService_GetBySourceID_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactInboxRepo(db) svc := NewContactInboxService(repo) _, err := svc.GetBySourceID(context.Background(), 1, "nonexistent") require.Error(t, err) } func TestContactInboxService_FilterContactInboxes_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewContactInboxRepo(db) svc := NewContactInboxService(repo) _, _, err := svc.FilterContactInboxes(context.Background(), 1, nil, nil, "", 0, 10) require.NoError(t, err) } func TestCustomFilterService_GetForUser_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomFilter{}) repo := repository.NewCustomFilterRepo(db) svc := NewCustomFilterService(repo) _, err := svc.GetForUser(context.Background(), 1, 1, 99999) require.Error(t, err) } func TestCustomFilterService_ListForUser_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomFilter{}) repo := repository.NewCustomFilterRepo(db) svc := NewCustomFilterService(repo) _, _, err := svc.ListForUser(context.Background(), 1, 1, "", 0, 10) require.NoError(t, err) } func TestCustomFilterService_DeleteForUser_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomFilter{}) repo := repository.NewCustomFilterRepo(db) svc := NewCustomFilterService(repo) err := svc.DeleteForUser(context.Background(), 1, 1, 99999) _ = err } func TestWebhookSubscriptionService_GetWebhook_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.WebhookSubscription{}) repo := repository.NewWebhookSubscriptionRepo(db) svc := NewWebhookSubscriptionService(repo) _, err := svc.GetWebhook(context.Background(), 1, 99999) require.Error(t, err) } func TestWebhookSubscriptionService_DeleteWebhook_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.WebhookSubscription{}) repo := repository.NewWebhookSubscriptionRepo(db) svc := NewWebhookSubscriptionService(repo) err := svc.DeleteWebhook(context.Background(), 1, 99999) _ = err } func TestCustomAttributeDefinitionService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.CustomAttributeDefinition{}) repo := repository.NewCustomAttributeDefinitionRepo(db) svc := NewCustomAttributeDefinitionService(repo) err := svc.Delete(context.Background(), 1, 99999) _ = err } func TestAgentCapacityPolicyService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.AgentCapacityPolicy{}) repo := repository.NewAgentCapacityPolicyRepo(db) svc := NewAgentCapacityPolicyService(repo) err := svc.Delete(context.Background(), 99999, 1) _ = err } func TestAgentCapacityPolicyService_ListUsers_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.AgentCapacityPolicy{}) repo := repository.NewAgentCapacityPolicyRepo(db) svc := NewAgentCapacityPolicyService(repo) _, err := svc.ListUsers(context.Background(), 1, 1) _ = err } func TestFolderService_Delete_NotFound2_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Folder{}) repo := repository.NewFolderRepo(db) svc := NewFolderService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestPortalMemberService_ListByUserID_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.PortalMember{}) repo := repository.NewPortalMemberRepo(db) svc := NewPortalMemberService(repo) _, _, err := svc.ListByUserID(context.Background(), 1, 0, 10) require.NoError(t, err) } func TestPortalMemberService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.PortalMember{}) repo := repository.NewPortalMemberRepo(db) svc := NewPortalMemberService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestDeliveryStatusService_Create_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.DeliveryStatus{}) msgRepo := repository.NewMessageRepo(db) dsRepo := repository.NewDeliveryStatusRepo(db) svc := NewDeliveryStatusService(msgRepo, dsRepo) _, err := svc.Create(context.Background(), 1, CreateDeliveryStatusRequest{}) _ = err } func TestConversationParticipantService_SetAssignableAgentService_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.ConversationParticipant{}) repo := repository.NewConversationParticipantRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewConversationParticipantService(repo, convRepo) svc.SetAssignableAgentService(nil) } func TestInstallationConfigService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.InstallationConfig{}) repo := repository.NewInstallationConfigRepo(db) svc := NewInstallationConfigService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestInboxLimitService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.InboxLimit{}) repo := repository.NewInboxLimitRepo(db) svc := NewInboxLimitService(repo) err := svc.Delete(context.Background(), 99999) _ = err } func TestTeamService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Team{}, &model.TeamMember{}) repo := repository.NewTeamRepo(db) memberRepo := repository.NewTeamMemberRepo(db) svc := NewTeamService(repo, memberRepo, db) err := svc.Delete(context.Background(), 99999, 1) _ = err } func TestTeamService_ListMembers_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Team{}, &model.TeamMember{}) repo := repository.NewTeamRepo(db) memberRepo := repository.NewTeamMemberRepo(db) svc := NewTeamService(repo, memberRepo, db) _, err := svc.ListMembers(context.Background(), 1, 1) _ = err } func TestCompanyService_Delete_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Company{}) companyRepo := repository.NewCompanyRepo(db) contactRepo := repository.NewContactRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewCompanyService(companyRepo, contactRepo, convRepo) err := svc.Delete(context.Background(), 99999, 1) _ = err } func TestCompanyService_ListContacts_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Company{}) companyRepo := repository.NewCompanyRepo(db) contactRepo := repository.NewContactRepo(db) convRepo := repository.NewConversationRepo(db) svc := NewCompanyService(companyRepo, contactRepo, convRepo) _, _, err := svc.ListContacts(context.Background(), 1, 1, 0, 10) _ = err } func TestNotificationSettingService_Update_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.NotificationSetting{}) repo := repository.NewNotificationSettingRepo(db) svc := NewNotificationSettingService(repo) _, err := svc.Update(context.Background(), 1, 1, UpdateNotificationSettingRequest{}) _ = err } func TestAuditService_GetByIDForAccount_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t, &model.Audit{}) repo := repository.NewAuditRepo(db) svc := NewAuditService(repo) _, err := svc.GetByIDForAccount(context.Background(), 1, 99999) require.Error(t, err) } func TestAgentBotInboxService_ListActiveByInbox_Empty_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewAgentBotInboxRepo(db) botRepo := repository.NewAgentBotRepo(db) svc := NewAgentBotInboxService(repo, botRepo) _, err := svc.ListActiveByInbox(context.Background(), 1) require.NoError(t, err) } func TestAgentBotInboxService_Unbind_NotFound_Cov20(t *testing.T) { db := newSimpleServiceTestDB(t) repo := repository.NewAgentBotInboxRepo(db) botRepo := repository.NewAgentBotRepo(db) svc := NewAgentBotInboxService(repo, botRepo) err := svc.Unbind(context.Background(), 99999) _ = err }