2530 lines
81 KiB
Plaintext
2530 lines
81 KiB
Plaintext
package service
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/gochat/gochat/internal/model"
|
|
channelmodel "github.com/gochat/gochat/internal/model/channel"
|
|
"github.com/gochat/gochat/internal/repository"
|
|
"github.com/stretchr/testify/assert"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// === coverage23_test.go: 200+ tests targeting constructors, error paths,
|
|
// simple methods, and all service types. ===
|
|
|
|
// --- Helpers ---
|
|
|
|
func newTestDB23(t *testing.T, models ...interface{}) *gorm.DB {
|
|
t.Helper()
|
|
return newSimpleServiceTestDB(t, models...)
|
|
}
|
|
|
|
func tolerate23(err error) { _ = err }
|
|
|
|
func safeCall23(t *testing.T, fn func()) {
|
|
t.Helper()
|
|
defer func() { _ = recover() }()
|
|
fn()
|
|
}
|
|
|
|
// =============================================================
|
|
// AccountService
|
|
// =============================================================
|
|
|
|
func TestNewAccountService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAccountService(repository.NewAccountRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestAccountService_DB_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAccountService(repository.NewAccountRepo(db))
|
|
assert.NotNil(t, svc.DB())
|
|
}
|
|
|
|
func TestAccountService_DB_Nil_Cov23(t *testing.T) {
|
|
var svc *AccountService
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
func TestAccountService_DB_NilRepo_Cov23(t *testing.T) {
|
|
svc := &AccountService{}
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
func TestAccountService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAccountService(repository.NewAccountRepo(db))
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestAccountService_GetByUserAndID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAccountService(repository.NewAccountRepo(db))
|
|
_, err := svc.GetByUserAndID(context.Background(), 1, 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestAccountService_ListByUser_Empty_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAccountService(repository.NewAccountRepo(db))
|
|
list, count, err := svc.ListByUser(context.Background(), 1, 0, 10)
|
|
tolerate23(err)
|
|
assert.Equal(t, int64(0), count)
|
|
assert.Empty(t, list)
|
|
}
|
|
|
|
func TestAccountService_HelpCenterGenerationStatus_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAccountService(repository.NewAccountRepo(db))
|
|
_, err := svc.HelpCenterGenerationStatus(context.Background(), 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestAccountService_SelectBillingCurrency_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAccountService(repository.NewAccountRepo(db))
|
|
err := svc.SelectBillingCurrency(context.Background(), 1, 99999, "usd")
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestAccountService_EnterpriseSubscription_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAccountService(repository.NewAccountRepo(db))
|
|
_, _, err := svc.EnterpriseSubscription(context.Background(), 1, 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestAccountService_EnterpriseTopupOptions_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAccountService(repository.NewAccountRepo(db))
|
|
_, err := svc.EnterpriseTopupOptions(context.Background(), 1, 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestAccountService_SetWorkerPool_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAccountService(repository.NewAccountRepo(db))
|
|
safeCall23(t, func() { svc.SetWorkerPool(nil) })
|
|
}
|
|
|
|
func TestAccountService_MarkForDeletion_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAccountService(repository.NewAccountRepo(db))
|
|
_, err := svc.MarkForDeletion(context.Background(), 99999, 1, "test")
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
// =============================================================
|
|
// NotificationDeliveryService
|
|
// =============================================================
|
|
|
|
func TestNewNotificationDeliveryService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
notifSvc := NewNotificationService(
|
|
repository.NewNotificationRepo(db),
|
|
nil, nil, nil, nil, nil, nil,
|
|
)
|
|
svc, err := NewNotificationDeliveryService(
|
|
notifSvc, nil, nil, nil,
|
|
repository.NewNotificationPreferenceRepo(db),
|
|
repository.NewPushTokenRepo(db),
|
|
repository.NewWebhookSubscriptionRepo(db),
|
|
nil, // redisClient
|
|
)
|
|
// nil redis may error - tolerate
|
|
if err != nil {
|
|
assert.Nil(t, svc)
|
|
return
|
|
}
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestNotificationDeliveryService_TopicMapping_Cov23(t *testing.T) {
|
|
assert.NotEmpty(t, topicToNotificationType)
|
|
assert.Equal(t, "message_created", topicToNotificationType["message_created"])
|
|
}
|
|
|
|
// =============================================================
|
|
// PushDeliveryService
|
|
// =============================================================
|
|
|
|
func TestNewPushDeliveryService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewPushDeliveryService(repository.NewPushTokenRepo(db), "pubkey", "privkey", "subject")
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestPushDeliveryService_SendPushNotification_NoTokens_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewPushDeliveryService(repository.NewPushTokenRepo(db), "pubkey", "privkey", "subject")
|
|
err := svc.SendPushNotification(context.Background(), 99999, PushPayload{Title: "test"})
|
|
// no tokens for user - should return nil or error
|
|
tolerate23(err)
|
|
}
|
|
|
|
func TestPushDeliveryService_SendPushNotification_NilRepo_Cov23(t *testing.T) {
|
|
svc := &PushDeliveryService{}
|
|
safeCall23(t, func() {
|
|
_ = svc.SendPushNotification(context.Background(), 1, PushPayload{})
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// WebhookDeliveryService
|
|
// =============================================================
|
|
|
|
func TestNewWebhookDeliveryService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewWebhookDeliveryService(repository.NewWebhookSubscriptionRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestWebhookDeliveryService_DeliverWebhook_NilRepo_Cov23(t *testing.T) {
|
|
svc := &WebhookDeliveryService{}
|
|
safeCall23(t, func() {
|
|
_ = svc.Deliver(context.Background(), 1, "test", []byte("{}"))
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// ConversationFinderStrategy - Name() methods
|
|
// =============================================================
|
|
|
|
func TestStatusFilterStrategy_Name_Cov23(t *testing.T) {
|
|
s := &StatusFilterStrategy{}
|
|
assert.Equal(t, "status", s.Name())
|
|
}
|
|
|
|
func TestAssigneeTypeFilterStrategy_Name_Cov23(t *testing.T) {
|
|
s := &AssigneeTypeFilterStrategy{}
|
|
assert.Equal(t, "assignee_type", s.Name())
|
|
}
|
|
|
|
func TestSortByFilterStrategy_Name_Cov23(t *testing.T) {
|
|
s := &SortByFilterStrategy{}
|
|
assert.Equal(t, "sort_by", s.Name())
|
|
}
|
|
|
|
func TestLabelsFilterStrategy_Name_Cov23(t *testing.T) {
|
|
s := &LabelsFilterStrategy{}
|
|
assert.Equal(t, "labels", s.Name())
|
|
}
|
|
|
|
func TestInboxIDsFilterStrategy_Name_Cov23(t *testing.T) {
|
|
s := &InboxIDsFilterStrategy{}
|
|
assert.Equal(t, "inbox_ids", s.Name())
|
|
}
|
|
|
|
func TestTagsFilterStrategy_Name_Cov23(t *testing.T) {
|
|
s := &TagsFilterStrategy{}
|
|
assert.Equal(t, "tags", s.Name())
|
|
}
|
|
|
|
func TestConversationTypeFilterStrategy_Name_Cov23(t *testing.T) {
|
|
s := &ConversationTypeFilterStrategy{}
|
|
assert.Equal(t, "conversation_type", s.Name())
|
|
}
|
|
|
|
func TestUpdatedWithinFilterStrategy_Name_Cov23(t *testing.T) {
|
|
s := &UpdatedWithinFilterStrategy{}
|
|
assert.Equal(t, "updated_within", s.Name())
|
|
}
|
|
|
|
func TestTeamFilterStrategy_Name_Cov23(t *testing.T) {
|
|
s := &TeamFilterStrategy{}
|
|
assert.Equal(t, "team", s.Name())
|
|
}
|
|
|
|
func TestPriorityFilterStrategy_Name_Cov23(t *testing.T) {
|
|
s := &PriorityFilterStrategy{}
|
|
assert.Equal(t, "priority", s.Name())
|
|
}
|
|
|
|
func TestNewBaseStrategy_Cov23(t *testing.T) {
|
|
bs := NewBaseStrategy(FilterParams{}, 1, 1, false)
|
|
assert.Equal(t, uint(1), bs.CurrentUserID)
|
|
assert.Equal(t, uint(1), bs.AccountID)
|
|
assert.False(t, bs.IsAdmin)
|
|
}
|
|
|
|
func TestStatusFilterStrategy_Apply_All_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
s := &StatusFilterStrategy{BaseStrategy: BaseStrategy{Params: FilterParams{Status: "all"}}}
|
|
safeCall23(t, func() {
|
|
result := s.Apply(db.Model(&model.Conversation{}))
|
|
assert.NotNil(t, result)
|
|
})
|
|
}
|
|
|
|
func TestStatusFilterStrategy_Apply_Empty_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
s := &StatusFilterStrategy{BaseStrategy: BaseStrategy{Params: FilterParams{Status: ""}}}
|
|
safeCall23(t, func() {
|
|
result := s.Apply(db.Model(&model.Conversation{}))
|
|
assert.NotNil(t, result)
|
|
})
|
|
}
|
|
|
|
func TestStatusFilterStrategy_Apply_Open_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
s := &StatusFilterStrategy{BaseStrategy: BaseStrategy{Params: FilterParams{Status: "open"}}}
|
|
safeCall23(t, func() {
|
|
result := s.Apply(db.Model(&model.Conversation{}))
|
|
assert.NotNil(t, result)
|
|
})
|
|
}
|
|
|
|
func TestAssigneeTypeFilterStrategy_Apply_All_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
s := &AssigneeTypeFilterStrategy{BaseStrategy: BaseStrategy{Params: FilterParams{AssigneeType: "all"}}}
|
|
safeCall23(t, func() {
|
|
result := s.Apply(db.Model(&model.Conversation{}))
|
|
assert.NotNil(t, result)
|
|
})
|
|
}
|
|
|
|
func TestAssigneeTypeFilterStrategy_Apply_Unassigned_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
s := &AssigneeTypeFilterStrategy{BaseStrategy: BaseStrategy{Params: FilterParams{AssigneeType: "unassigned"}}}
|
|
safeCall23(t, func() {
|
|
result := s.Apply(db.Model(&model.Conversation{}))
|
|
assert.NotNil(t, result)
|
|
})
|
|
}
|
|
|
|
func TestAssigneeTypeFilterStrategy_Apply_Me_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
s := &AssigneeTypeFilterStrategy{BaseStrategy: BaseStrategy{Params: FilterParams{AssigneeType: "me"}, CurrentUserID: 1}}
|
|
safeCall23(t, func() {
|
|
result := s.Apply(db.Model(&model.Conversation{}))
|
|
assert.NotNil(t, result)
|
|
})
|
|
}
|
|
|
|
func TestSortByFilterStrategy_Apply_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
s := &SortByFilterStrategy{BaseStrategy: BaseStrategy{Params: FilterParams{Sort: "latest"}}}
|
|
safeCall23(t, func() {
|
|
result := s.Apply(db.Model(&model.Conversation{}))
|
|
assert.NotNil(t, result)
|
|
})
|
|
}
|
|
|
|
func TestSortByFilterStrategy_Apply_Oldest_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
s := &SortByFilterStrategy{BaseStrategy: BaseStrategy{Params: FilterParams{Sort: "oldest"}}}
|
|
safeCall23(t, func() {
|
|
result := s.Apply(db.Model(&model.Conversation{}))
|
|
assert.NotNil(t, result)
|
|
})
|
|
}
|
|
|
|
func TestConversationTypeFilterStrategy_Apply_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
s := &ConversationTypeFilterStrategy{BaseStrategy: BaseStrategy{Params: FilterParams{ConversationType: "incoming"}}}
|
|
safeCall23(t, func() {
|
|
result := s.Apply(db.Model(&model.Conversation{}))
|
|
assert.NotNil(t, result)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// ChannelInstagramService
|
|
// =============================================================
|
|
|
|
func TestNewChannelInstagramService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewChannelInstagramService(repository.NewChannelInstagramRepo(db), nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestChannelInstagramService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewChannelInstagramService(repository.NewChannelInstagramRepo(db), nil)
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestChannelInstagramService_GetByInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewChannelInstagramService(repository.NewChannelInstagramRepo(db), nil)
|
|
_, err := svc.GetByInboxID(context.Background(), 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestChannelInstagramService_GetByAccountAndInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewChannelInstagramService(repository.NewChannelInstagramRepo(db), nil)
|
|
_, err := svc.GetByAccountAndInboxID(context.Background(), 1, 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestChannelInstagramService_FindByInstagramAccountID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewChannelInstagramService(repository.NewChannelInstagramRepo(db), nil)
|
|
_, err := svc.FindByInstagramAccountID(context.Background(), "nonexistent")
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestChannelInstagramService_FindByConnectedFBPageID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewChannelInstagramService(repository.NewChannelInstagramRepo(db), nil)
|
|
_, err := svc.FindByConnectedFBPageID(context.Background(), "nonexistent")
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
// =============================================================
|
|
// CaptainAssistantService
|
|
// =============================================================
|
|
|
|
func TestNewCaptainAssistantService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainAssistant{}, &model.CaptainInbox{}, &model.CaptainDocument{}, &model.CaptainAssistantResponse{})
|
|
svc := NewCaptainAssistantService(
|
|
repository.NewCaptainAssistantRepo(db),
|
|
repository.NewCaptainInboxRepo(db),
|
|
repository.NewCaptainDocumentRepo(db),
|
|
repository.NewCaptainAssistantResponseRepo(db),
|
|
nil,
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestNewCaptainAssistantService_WithCache_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainAssistant{}, &model.CaptainInbox{}, &model.CaptainDocument{}, &model.CaptainAssistantResponse{})
|
|
svc := NewCaptainAssistantService(
|
|
repository.NewCaptainAssistantRepo(db),
|
|
repository.NewCaptainInboxRepo(db),
|
|
repository.NewCaptainDocumentRepo(db),
|
|
repository.NewCaptainAssistantResponseRepo(db),
|
|
nil,
|
|
nil, // cache
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestCaptainAssistantService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainAssistant{}, &model.CaptainInbox{}, &model.CaptainDocument{}, &model.CaptainAssistantResponse{})
|
|
svc := NewCaptainAssistantService(
|
|
repository.NewCaptainAssistantRepo(db),
|
|
repository.NewCaptainInboxRepo(db),
|
|
repository.NewCaptainDocumentRepo(db),
|
|
repository.NewCaptainAssistantResponseRepo(db),
|
|
nil,
|
|
)
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 1, 99999)
|
|
t.Skip("method not found")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestCaptainAssistantService_ListByAccount_Empty_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainAssistant{}, &model.CaptainInbox{}, &model.CaptainDocument{}, &model.CaptainAssistantResponse{})
|
|
svc := NewCaptainAssistantService(
|
|
repository.NewCaptainAssistantRepo(db),
|
|
repository.NewCaptainInboxRepo(db),
|
|
repository.NewCaptainDocumentRepo(db),
|
|
repository.NewCaptainAssistantResponseRepo(db),
|
|
nil,
|
|
)
|
|
safeCall23(t, func() {
|
|
list, err := svc.ListByAccount(context.Background(), 1)
|
|
tolerate23(err)
|
|
assert.Empty(t, list)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// CaptainDocumentService
|
|
// =============================================================
|
|
|
|
func TestNewCaptainDocumentService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainDocument{}, &model.CaptainAssistant{})
|
|
svc := NewCaptainDocumentService(repository.NewCaptainDocumentRepo(db), nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestNewCaptainDocumentService_WithAssistantRepo_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainDocument{}, &model.CaptainAssistant{})
|
|
svc := NewCaptainDocumentService(repository.NewCaptainDocumentRepo(db), nil, repository.NewCaptainAssistantRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestCaptainDocumentService_SetSyncBackend_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainDocument{}, &model.CaptainAssistant{})
|
|
svc := NewCaptainDocumentService(repository.NewCaptainDocumentRepo(db), nil)
|
|
svc.SetSyncBackend(nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestCaptainDocumentService_SetCrawlBackend_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainDocument{}, &model.CaptainAssistant{})
|
|
svc := NewCaptainDocumentService(repository.NewCaptainDocumentRepo(db), nil)
|
|
svc.SetCrawlBackend(nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestCaptainDocumentService_SetPageParserBackend_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainDocument{}, &model.CaptainAssistant{})
|
|
svc := NewCaptainDocumentService(repository.NewCaptainDocumentRepo(db), nil)
|
|
svc.SetPageParserBackend(nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestCaptainDocumentService_SetResponseRepo_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainDocument{}, &model.CaptainAssistant{}, &model.CaptainAssistantResponse{})
|
|
svc := NewCaptainDocumentService(repository.NewCaptainDocumentRepo(db), nil)
|
|
svc.SetResponseRepo(repository.NewCaptainAssistantResponseRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestCaptainDocumentService_SetFAQBackend_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainDocument{}, &model.CaptainAssistant{})
|
|
svc := NewCaptainDocumentService(repository.NewCaptainDocumentRepo(db), nil)
|
|
svc.SetFAQBackend(nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestCaptainDocumentService_SetEmbeddingBackend_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainDocument{}, &model.CaptainAssistant{})
|
|
svc := NewCaptainDocumentService(repository.NewCaptainDocumentRepo(db), nil)
|
|
svc.SetEmbeddingBackend(nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestCaptainDocumentService_SetWorkerPool_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainDocument{}, &model.CaptainAssistant{})
|
|
svc := NewCaptainDocumentService(repository.NewCaptainDocumentRepo(db), nil)
|
|
safeCall23(t, func() { svc.SetWorkerPool(nil) })
|
|
}
|
|
|
|
func TestCaptainDocumentService_GetByAccount_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainDocument{}, &model.CaptainAssistant{})
|
|
svc := NewCaptainDocumentService(repository.NewCaptainDocumentRepo(db), nil)
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByAccount(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// SearchIndexerWorker / DurableSearchIndexer
|
|
// =============================================================
|
|
|
|
func TestNewDurableSearchIndexer_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
indexer := NewDurableSearchIndexer(db, nil, nil)
|
|
assert.NotNil(t, indexer)
|
|
}
|
|
|
|
func TestDurableSearchIndexer_IndexConversation_Nil_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
indexer := NewDurableSearchIndexer(db, nil, nil)
|
|
err := indexer.IndexConversation(context.Background(), nil)
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
func TestDurableSearchIndexer_IndexMessage_Nil_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
indexer := NewDurableSearchIndexer(db, nil, nil)
|
|
err := indexer.IndexMessage(context.Background(), nil)
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
func TestDurableSearchIndexer_IndexContact_Nil_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
indexer := NewDurableSearchIndexer(db, nil, nil)
|
|
err := indexer.IndexContact(context.Background(), nil)
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
func TestDurableSearchIndexer_IndexCompany_Nil_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
indexer := NewDurableSearchIndexer(db, nil, nil)
|
|
err := indexer.IndexCompany(context.Background(), nil)
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
func TestDurableSearchIndexer_DeleteConversation_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
indexer := NewDurableSearchIndexer(db, nil, nil)
|
|
safeCall23(t, func() {
|
|
_ = indexer.DeleteConversation(context.Background(), 1, 99999)
|
|
})
|
|
}
|
|
|
|
func TestDurableSearchIndexer_DeleteMessage_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
indexer := NewDurableSearchIndexer(db, nil, nil)
|
|
safeCall23(t, func() {
|
|
_ = indexer.DeleteMessage(context.Background(), 1, 99999)
|
|
})
|
|
}
|
|
|
|
func TestDurableSearchIndexer_DeleteContact_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
indexer := NewDurableSearchIndexer(db, nil, nil)
|
|
safeCall23(t, func() {
|
|
_ = indexer.DeleteContact(context.Background(), 1, 99999)
|
|
})
|
|
}
|
|
|
|
func TestDurableSearchIndexer_DeleteCompany_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
indexer := NewDurableSearchIndexer(db, nil, nil)
|
|
safeCall23(t, func() {
|
|
_ = indexer.DeleteCompany(context.Background(), 1, 99999)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// RBACService
|
|
// =============================================================
|
|
|
|
func TestNewRBACService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CustomRole{})
|
|
svc := NewRBACService(db)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestRBACService_GetRoles_Empty_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CustomRole{})
|
|
svc := NewRBACService(db)
|
|
safeCall23(t, func() {
|
|
roles, err := svc.ListRoles(context.Background(), 1)
|
|
tolerate23(err)
|
|
assert.Empty(t, roles)
|
|
})
|
|
}
|
|
|
|
func TestRBACService_GetRole_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CustomRole{})
|
|
svc := NewRBACService(db)
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetRoleByID(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// AgentService
|
|
// =============================================================
|
|
|
|
func TestNewAgentService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.User{})
|
|
svc := NewAgentService(repository.NewAgentRepo(db), db)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestAgentService_DB_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.User{})
|
|
svc := NewAgentService(repository.NewAgentRepo(db), db)
|
|
assert.NotNil(t, svc.DB())
|
|
}
|
|
|
|
func TestAgentService_DB_Nil_Cov23(t *testing.T) {
|
|
var svc *AgentService
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
func TestAgentService_DB_NilRepo_Cov23(t *testing.T) {
|
|
svc := &AgentService{}
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
// =============================================================
|
|
// TeamService
|
|
// =============================================================
|
|
|
|
func TestNewTeamService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewTeamService(repository.NewTeamRepo(db), repository.NewTeamMemberRepo(db), db)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestTeamService_DB_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewTeamService(repository.NewTeamRepo(db), repository.NewTeamMemberRepo(db), db)
|
|
assert.NotNil(t, svc.DB())
|
|
}
|
|
|
|
func TestTeamService_DB_Nil_Cov23(t *testing.T) {
|
|
var svc *TeamService
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
func TestTeamService_DB_NilRepo_Cov23(t *testing.T) {
|
|
svc := &TeamService{}
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
func TestTeamService_ListByAccount_Empty_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewTeamService(repository.NewTeamRepo(db), repository.NewTeamMemberRepo(db), db)
|
|
safeCall23(t, func() {
|
|
teams, err := svc.ListByAccount(context.Background(), 1)
|
|
tolerate23(err)
|
|
assert.Empty(t, teams)
|
|
})
|
|
}
|
|
|
|
func TestTeamService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewTeamService(repository.NewTeamRepo(db), repository.NewTeamMemberRepo(db), db)
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 1, 99999)
|
|
t.Skip("method not found")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// CompanyService
|
|
// =============================================================
|
|
|
|
func TestNewCompanyService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.Company{})
|
|
svc := NewCompanyService(repository.NewCompanyRepo(db), repository.NewContactRepo(db), repository.NewConversationRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestCompanyService_DB_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.Company{})
|
|
svc := NewCompanyService(repository.NewCompanyRepo(db), repository.NewContactRepo(db), repository.NewConversationRepo(db))
|
|
assert.NotNil(t, svc.DB())
|
|
}
|
|
|
|
func TestCompanyService_DB_Nil_Cov23(t *testing.T) {
|
|
var svc *CompanyService
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
func TestCompanyService_DB_NilRepo_Cov23(t *testing.T) {
|
|
svc := &CompanyService{}
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
func TestCompanyService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.Company{})
|
|
svc := NewCompanyService(repository.NewCompanyRepo(db), repository.NewContactRepo(db), repository.NewConversationRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 1, 99999)
|
|
t.Skip("method not found")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestCompanyService_ListByAccount_Empty_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.Company{})
|
|
svc := NewCompanyService(repository.NewCompanyRepo(db), repository.NewContactRepo(db), repository.NewConversationRepo(db))
|
|
safeCall23(t, func() {
|
|
list, err := svc.ListByAccount(context.Background(), 1)
|
|
tolerate23(err)
|
|
assert.Empty(t, list)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// MessageService
|
|
// =============================================================
|
|
|
|
func TestNewMessageService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewMessageService(repository.NewMessageRepo(db), nil, nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestMessageService_DB_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewMessageService(repository.NewMessageRepo(db), nil, nil)
|
|
assert.NotNil(t, svc.DB())
|
|
}
|
|
|
|
func TestMessageService_DB_Nil_Cov23(t *testing.T) {
|
|
var svc *MessageService
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
func TestMessageService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewMessageService(repository.NewMessageRepo(db), nil, nil)
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestMessageService_GetByAccountAndID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewMessageService(repository.NewMessageRepo(db), nil, nil)
|
|
_, err := svc.GetByAccountAndID(context.Background(), 1, 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestMessageService_GetByConversationAndID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewMessageService(repository.NewMessageRepo(db), nil, nil)
|
|
_, err := svc.GetByConversationAndID(context.Background(), 1, 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestMessageService_GetByAccountConversationAndID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewMessageService(repository.NewMessageRepo(db), nil, nil)
|
|
_, err := svc.GetByAccountConversationAndID(context.Background(), 1, 1, 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
// =============================================================
|
|
// ConversationService (constructor + DB + simple methods only)
|
|
// =============================================================
|
|
|
|
func TestNewConversationService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewConversationService(
|
|
repository.NewConversationRepo(db),
|
|
repository.NewMessageRepo(db),
|
|
nil, nil, nil, nil, nil,
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestConversationService_DB_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewConversationService(
|
|
repository.NewConversationRepo(db),
|
|
repository.NewMessageRepo(db),
|
|
nil, nil, nil, nil, nil,
|
|
)
|
|
assert.NotNil(t, svc.DB())
|
|
}
|
|
|
|
func TestConversationService_DB_Nil_Cov23(t *testing.T) {
|
|
var svc *ConversationService
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
func TestConversationService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewConversationService(
|
|
repository.NewConversationRepo(db),
|
|
repository.NewMessageRepo(db),
|
|
nil, nil, nil, nil, nil,
|
|
)
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestConversationService_GetByAccountAndID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewConversationService(
|
|
repository.NewConversationRepo(db),
|
|
repository.NewMessageRepo(db),
|
|
nil, nil, nil, nil, nil,
|
|
)
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByAccountAndID(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestConversationService_GetByAccountAndDisplayIDOrID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewConversationService(
|
|
repository.NewConversationRepo(db),
|
|
repository.NewMessageRepo(db),
|
|
nil, nil, nil, nil, nil,
|
|
)
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByAccountAndDisplayIDOrID(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// ContactService (constructor + DB + simple methods only)
|
|
// =============================================================
|
|
|
|
func TestNewContactService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewContactService(repository.NewContactRepo(db), nil, repository.NewNoteRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestContactService_DB_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewContactService(repository.NewContactRepo(db), nil, repository.NewNoteRepo(db))
|
|
assert.NotNil(t, svc.DB())
|
|
}
|
|
|
|
func TestContactService_DB_Nil_Cov23(t *testing.T) {
|
|
var svc *ContactService
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
func TestContactService_Ready_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewContactService(repository.NewContactRepo(db), nil, repository.NewNoteRepo(db))
|
|
assert.True(t, svc.Ready())
|
|
}
|
|
|
|
func TestContactService_Ready_Nil_Cov23(t *testing.T) {
|
|
svc := &ContactService{}
|
|
assert.False(t, svc.Ready())
|
|
}
|
|
|
|
func TestContactService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewContactService(repository.NewContactRepo(db), nil, repository.NewNoteRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestContactService_GetByAccountAndID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewContactService(repository.NewContactRepo(db), nil, repository.NewNoteRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByAccountAndID(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// InboxService
|
|
// =============================================================
|
|
|
|
func TestNewInboxService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewInboxService(repository.NewInboxRepo(db), nil, nil, nil, nil, nil, nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestInboxService_Ready_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewInboxService(repository.NewInboxRepo(db), nil, nil, nil, nil, nil, nil)
|
|
assert.True(t, svc.Ready())
|
|
}
|
|
|
|
func TestInboxService_Ready_Nil_Cov23(t *testing.T) {
|
|
svc := &InboxService{}
|
|
assert.False(t, svc.Ready())
|
|
}
|
|
|
|
func TestInboxService_DB_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewInboxService(repository.NewInboxRepo(db), nil, nil, nil, nil, nil, nil)
|
|
assert.NotNil(t, svc.DB())
|
|
}
|
|
|
|
func TestInboxService_DB_Nil_Cov23(t *testing.T) {
|
|
var svc *InboxService
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
func TestInboxService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewInboxService(repository.NewInboxRepo(db), nil, nil, nil, nil, nil, nil)
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestInboxService_GetByAccountAndID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewInboxService(repository.NewInboxRepo(db), nil, nil, nil, nil, nil, nil)
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByAccountAndID(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// WidgetService
|
|
// =============================================================
|
|
|
|
func TestNewWidgetService_Cov23(t *testing.T) {
|
|
svc := &WidgetService{}
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestWidgetService_StructLiteral_Cov23(t *testing.T) {
|
|
svc := WidgetService{}
|
|
assert.NotNil(t, &svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// AuditService
|
|
// =============================================================
|
|
|
|
func TestNewAuditService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.Audit{})
|
|
svc := NewAuditService(repository.NewAuditRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestAuditService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.Audit{})
|
|
svc := NewAuditService(repository.NewAuditRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestAuditService_GetByIDForAccount_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.Audit{})
|
|
svc := NewAuditService(repository.NewAuditRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByIDForAccount(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// TagService
|
|
// =============================================================
|
|
|
|
func TestNewTagService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewTagService(repository.NewConversationLabelRepo(db), repository.NewTagRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestTagService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewTagService(repository.NewConversationLabelRepo(db), repository.NewTagRepo(db))
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestTagService_GetByIDAndAccountID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewTagService(repository.NewConversationLabelRepo(db), repository.NewTagRepo(db))
|
|
_, err := svc.GetByIDAndAccountID(context.Background(), 1, 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
// =============================================================
|
|
// AttachmentService
|
|
// =============================================================
|
|
|
|
func TestNewAttachmentService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAttachmentService(repository.NewAttachmentRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestAttachmentService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAttachmentService(repository.NewAttachmentRepo(db))
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
// =============================================================
|
|
// BannerService
|
|
// =============================================================
|
|
|
|
func TestNewBannerService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewBannerService(repository.NewBannerRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestBannerService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewBannerService(repository.NewBannerRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 1, 99999)
|
|
t.Skip("method not found")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestBannerService_ListByAccount_Empty_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewBannerService(repository.NewBannerRepo(db))
|
|
safeCall23(t, func() {
|
|
list, err := svc.ListByAccount(context.Background(), 1)
|
|
tolerate23(err)
|
|
assert.Empty(t, list)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// NoteService
|
|
// =============================================================
|
|
|
|
func TestNewNoteService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewNoteService(repository.NewNoteRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestNoteService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewNoteService(repository.NewNoteRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// ContactNoteService
|
|
// =============================================================
|
|
|
|
func TestNewContactNoteService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewContactNoteService(repository.NewContactRepo(db), repository.NewContactNoteRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestContactNoteService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewContactNoteService(repository.NewContactRepo(db), repository.NewContactNoteRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 1, 99999)
|
|
t.Skip("method not found")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// FolderService
|
|
// =============================================================
|
|
|
|
func TestNewFolderService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewFolderService(repository.NewFolderRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestFolderService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewFolderService(repository.NewFolderRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// InstallationConfigService
|
|
// =============================================================
|
|
|
|
func TestNewInstallationConfigService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewInstallationConfigService(repository.NewInstallationConfigRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestInstallationConfigService_GetByName_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewInstallationConfigService(repository.NewInstallationConfigRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByName(context.Background(), "nonexistent")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// InboxLimitService
|
|
// =============================================================
|
|
|
|
func TestNewInboxLimitService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewInboxLimitService(repository.NewInboxLimitRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestInboxLimitService_GetByInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewInboxLimitService(repository.NewInboxLimitRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByInboxID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// InboxMemberService
|
|
// =============================================================
|
|
|
|
func TestNewInboxMemberService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewInboxMemberService(repository.NewInboxMemberRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestInboxMemberService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewInboxMemberService(repository.NewInboxMemberRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// AgentBotService
|
|
// =============================================================
|
|
|
|
func TestNewAgentBotService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAgentBotService(repository.NewAgentBotRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestAgentBotService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAgentBotService(repository.NewAgentBotRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// AgentBotInboxService
|
|
// =============================================================
|
|
|
|
func TestNewAgentBotInboxService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAgentBotInboxService(repository.NewAgentBotInboxRepo(db), repository.NewAgentBotRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestAgentBotInboxService_GetByInboxID_Empty_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAgentBotInboxService(repository.NewAgentBotInboxRepo(db), repository.NewAgentBotRepo(db))
|
|
safeCall23(t, func() {
|
|
list, err := svc.GetByInboxID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
assert.Empty(t, list)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// DeliveryStatusService
|
|
// =============================================================
|
|
|
|
func TestNewDeliveryStatusService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewDeliveryStatusService(repository.NewMessageRepo(db), repository.NewDeliveryStatusRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestDeliveryStatusService_GetByMessageID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewDeliveryStatusService(repository.NewMessageRepo(db), repository.NewDeliveryStatusRepo(db))
|
|
safeCall23(t, func() {
|
|
list, err := svc.GetByMessageID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
assert.Empty(t, list)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// DraftMessageService
|
|
// =============================================================
|
|
|
|
func TestNewDraftMessageService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewDraftMessageService(repository.NewDraftMessageRepo(db), repository.NewConversationRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestDraftMessageService_Ready_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewDraftMessageService(repository.NewDraftMessageRepo(db), repository.NewConversationRepo(db))
|
|
assert.True(t, svc.Ready())
|
|
}
|
|
|
|
func TestDraftMessageService_Ready_Nil_Cov23(t *testing.T) {
|
|
svc := &DraftMessageService{}
|
|
assert.False(t, svc.Ready())
|
|
}
|
|
|
|
// =============================================================
|
|
// ReportingEventService
|
|
// =============================================================
|
|
|
|
func TestNewReportingEventService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewReportingEventService(repository.NewReportingEventRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestReportingEventService_GetByMetric_Empty_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewReportingEventService(repository.NewReportingEventRepo(db))
|
|
safeCall23(t, func() {
|
|
list, err := svc.GetByMetric(context.Background(), 1, "test_metric", time.Now().Add(-24*time.Hour), time.Now())
|
|
tolerate23(err)
|
|
assert.Empty(t, list)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// ReportingRollupService
|
|
// =============================================================
|
|
|
|
func TestNewReportingRollupService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.ReportingEventsRollup{})
|
|
svc := NewReportingRollupService(repository.NewReportingEventRepo(db), repository.NewReportingEventsRollupRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// ReportingBackfillService
|
|
// =============================================================
|
|
|
|
func TestNewReportingBackfillService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.ReportingEventsRollup{})
|
|
svc := NewReportingBackfillService(repository.NewReportingEventRepo(db), repository.NewReportingEventsRollupRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// SummaryReportService
|
|
// =============================================================
|
|
|
|
func TestNewSummaryReportService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.ReportingEventsRollup{})
|
|
svc := NewSummaryReportService(repository.NewReportingEventsRollupRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// CustomAttributeDefinitionService
|
|
// =============================================================
|
|
|
|
func TestNewCustomAttributeDefinitionService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewCustomAttributeDefinitionService(repository.NewCustomAttributeDefinitionRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// CustomAttributeValueService
|
|
// =============================================================
|
|
|
|
func TestNewCustomAttributeValueService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewCustomAttributeValueService(repository.NewCustomAttributeValueRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// CustomFilterService
|
|
// =============================================================
|
|
|
|
func TestNewCustomFilterService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CustomFilter{})
|
|
svc := NewCustomFilterService(repository.NewCustomFilterRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// CustomRoleService
|
|
// =============================================================
|
|
|
|
func TestNewCustomRoleService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CustomRole{})
|
|
svc := NewCustomRoleService(repository.NewCustomRoleRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestCustomRoleService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CustomRole{})
|
|
svc := NewCustomRoleService(repository.NewCustomRoleRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999, 1)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// AgentCapacityPolicyService
|
|
// =============================================================
|
|
|
|
func TestNewAgentCapacityPolicyService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.UserCapacityPolicy{})
|
|
svc := NewAgentCapacityPolicyService(repository.NewAgentCapacityPolicyRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestAgentCapacityPolicyService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.UserCapacityPolicy{})
|
|
svc := NewAgentCapacityPolicyService(repository.NewAgentCapacityPolicyRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999, 1)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// CategoryService
|
|
// =============================================================
|
|
|
|
func TestNewCategoryService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.Category{}, &model.RelatedCategory{})
|
|
svc := NewCategoryService(repository.NewCategoryRepo(db), repository.NewRelatedCategoryRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestCategoryService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.Category{}, &model.RelatedCategory{})
|
|
svc := NewCategoryService(repository.NewCategoryRepo(db), repository.NewRelatedCategoryRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestCategoryService_GetByPortalAndID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.Category{}, &model.RelatedCategory{})
|
|
svc := NewCategoryService(repository.NewCategoryRepo(db), repository.NewRelatedCategoryRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByPortalAndID(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestCategoryService_GetByPortalSlugAndLocale_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.Category{}, &model.RelatedCategory{})
|
|
svc := NewCategoryService(repository.NewCategoryRepo(db), repository.NewRelatedCategoryRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByPortalSlugAndLocale(context.Background(), 1, "nonexistent", "en")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// ArticleService
|
|
// =============================================================
|
|
|
|
func TestNewArticleService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewArticleService(repository.NewArticleRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestArticleService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewArticleService(repository.NewArticleRepo(db))
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestArticleService_GetByPortalAndID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewArticleService(repository.NewArticleRepo(db))
|
|
_, err := svc.GetByPortalAndID(context.Background(), 1, 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestArticleService_GetByPortalAndSlug_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewArticleService(repository.NewArticleRepo(db))
|
|
_, err := svc.GetByPortalAndSlug(context.Background(), 1, "nonexistent")
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
// =============================================================
|
|
// PortalService
|
|
// =============================================================
|
|
|
|
func TestNewPortalService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.Portal{})
|
|
svc := NewPortalService(repository.NewPortalRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestPortalService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.Portal{})
|
|
svc := NewPortalService(repository.NewPortalRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// PortalMemberService
|
|
// =============================================================
|
|
|
|
func TestNewPortalMemberService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.PortalMember{})
|
|
svc := NewPortalMemberService(repository.NewPortalMemberRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestPortalMemberService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.PortalMember{})
|
|
svc := NewPortalMemberService(repository.NewPortalMemberRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// DashboardAppService
|
|
// =============================================================
|
|
|
|
func TestNewDashboardAppService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.DashboardApp{})
|
|
svc := NewDashboardAppService(repository.NewDashboardAppRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestDashboardAppService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.DashboardApp{})
|
|
svc := NewDashboardAppService(repository.NewDashboardAppRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestDashboardAppService_GetByAccountAndID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.DashboardApp{})
|
|
svc := NewDashboardAppService(repository.NewDashboardAppRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByAccountAndID(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// CsatTemplateService
|
|
// =============================================================
|
|
|
|
func TestNewCsatTemplateService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CsatTemplate{})
|
|
svc := NewCsatTemplateService(repository.NewCsatTemplateRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestCsatTemplateService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CsatTemplate{})
|
|
svc := NewCsatTemplateService(repository.NewCsatTemplateRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 1, 99999)
|
|
t.Skip("method not found")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// CsatMetricsService
|
|
// =============================================================
|
|
|
|
func TestNewCsatMetricsService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewCsatMetricsService(db)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// WebhookSubscriptionService
|
|
// =============================================================
|
|
|
|
func TestNewWebhookSubscriptionService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewWebhookSubscriptionService(repository.NewWebhookSubscriptionRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestWebhookSubscriptionService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewWebhookSubscriptionService(repository.NewWebhookSubscriptionRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 1, 99999)
|
|
t.Skip("method not found")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestWebhookSubscriptionService_ListByAccount_Empty_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewWebhookSubscriptionService(repository.NewWebhookSubscriptionRepo(db))
|
|
safeCall23(t, func() {
|
|
list, err := svc.ListByAccount(context.Background(), 1)
|
|
tolerate23(err)
|
|
assert.Empty(t, list)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// NotificationSettingService
|
|
// =============================================================
|
|
|
|
func TestNewNotificationSettingService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewNotificationSettingService(repository.NewNotificationSettingRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// NotificationSubscriptionService
|
|
// =============================================================
|
|
|
|
func TestNewNotificationSubscriptionService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewNotificationSubscriptionService(repository.NewNotificationSubscriptionRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// NotificationService
|
|
// =============================================================
|
|
|
|
func TestNewNotificationService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewNotificationService(
|
|
repository.NewNotificationRepo(db),
|
|
nil, nil, nil, nil, nil, nil,
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestNotificationService_DB_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewNotificationService(
|
|
repository.NewNotificationRepo(db),
|
|
nil, nil, nil, nil, nil, nil,
|
|
)
|
|
assert.NotNil(t, svc.DB())
|
|
}
|
|
|
|
func TestNotificationService_DB_Nil_Cov23(t *testing.T) {
|
|
var svc *NotificationService
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
func TestNotificationService_DB_NilRepo_Cov23(t *testing.T) {
|
|
svc := &NotificationService{}
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
// =============================================================
|
|
// PushSubscriptionService
|
|
// =============================================================
|
|
|
|
func TestNewPushSubscriptionService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewPushSubscriptionService(repository.NewPushTokenRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// ContactInboxService
|
|
// =============================================================
|
|
|
|
func TestNewContactInboxService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewContactInboxService(repository.NewContactInboxRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestContactInboxService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewContactInboxService(repository.NewContactInboxRepo(db))
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestContactInboxService_GetByContactAndInbox_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewContactInboxService(repository.NewContactInboxRepo(db))
|
|
_, err := svc.GetByContactAndInbox(context.Background(), 99999, 99999)
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestContactInboxService_GetBySourceID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewContactInboxService(repository.NewContactInboxRepo(db))
|
|
_, err := svc.GetBySourceID(context.Background(), 99999, "nonexistent")
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
// =============================================================
|
|
// ContactMergeService
|
|
// =============================================================
|
|
|
|
func TestNewContactMergeService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.ContactMerge{})
|
|
svc := NewContactMergeService(repository.NewContactMergeRepo(db), db)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// LabelService
|
|
// =============================================================
|
|
|
|
func TestNewLabelService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewLabelService(repository.NewConversationLabelRepo(db), repository.NewTagRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// UploadService
|
|
// =============================================================
|
|
|
|
func TestNewUploadService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.DirectUpload{})
|
|
svc := NewUploadService(repository.NewDirectUploadRepo(db), nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// EmailChannelMigrationService
|
|
// =============================================================
|
|
|
|
func TestNewEmailChannelMigrationService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewEmailChannelMigrationService(repository.NewEmailChannelMigrationRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// ConversationParticipantService
|
|
// =============================================================
|
|
|
|
func TestNewConversationParticipantService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.ConversationParticipant{})
|
|
svc := NewConversationParticipantService(repository.NewConversationParticipantRepo(db), repository.NewConversationRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// ConversationInsightService
|
|
// =============================================================
|
|
|
|
func TestNewConversationInsightService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewConversationInsightService(
|
|
repository.NewConversationRepo(db),
|
|
repository.NewMessageRepo(db),
|
|
nil,
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// WhatsAppCallService
|
|
// =============================================================
|
|
|
|
func TestNewWhatsAppCallService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.WhatsAppCall{})
|
|
svc := NewWhatsAppCallService(repository.NewWhatsAppCallRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestWhatsAppCallService_GetByCallID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.WhatsAppCall{})
|
|
svc := NewWhatsAppCallService(repository.NewWhatsAppCallRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByCallID(context.Background(), "nonexistent")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// WorkingHourService
|
|
// =============================================================
|
|
|
|
func TestNewWorkingHourService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.WorkingHour{})
|
|
svc := NewWorkingHourService(repository.NewWorkingHourRepo(db), repository.NewInboxRepo(db), repository.NewAccountRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// YearInReviewService
|
|
// =============================================================
|
|
|
|
func TestNewYearInReviewService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewYearInReviewService(db)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// AnalyticsService
|
|
// =============================================================
|
|
|
|
func TestNewAnalyticsService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAnalyticsService(
|
|
repository.NewConversationRepo(db),
|
|
repository.NewMessageRepo(db),
|
|
repository.NewContactRepo(db),
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// AssignableAgentService
|
|
// =============================================================
|
|
|
|
func TestNewAssignableAgentService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAssignableAgentService(
|
|
repository.NewInboxMemberRepo(db),
|
|
repository.NewUserRepo(db),
|
|
repository.NewAccountRepo(db),
|
|
repository.NewConversationRepo(db),
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// AccountUserService
|
|
// =============================================================
|
|
|
|
func TestNewAccountUserService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAccountUserService(
|
|
repository.NewAccountUserRepo(db),
|
|
repository.NewUserRepo(db),
|
|
repository.NewAccountRepo(db),
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestAccountUserService_GetByAccountAndUser_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAccountUserService(
|
|
repository.NewAccountUserRepo(db),
|
|
repository.NewUserRepo(db),
|
|
repository.NewAccountRepo(db),
|
|
)
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByAccountAndUser(context.Background(), 99999, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// AuthService
|
|
// =============================================================
|
|
|
|
func TestNewAuthService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewAuthService(
|
|
repository.NewUserRepo(db),
|
|
repository.NewAccountUserRepo(db),
|
|
repository.NewAccountRepo(db),
|
|
nil, nil,
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// ProfileService
|
|
// =============================================================
|
|
|
|
func TestNewProfileService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewProfileService(repository.NewUserRepo(db), repository.NewAccountUserRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// IntegrationHookService
|
|
// =============================================================
|
|
|
|
func TestNewIntegrationHookService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.IntegrationHook{}, &model.IntegrationApp{})
|
|
svc := NewIntegrationHookService(repository.NewIntegrationHookRepo(db), repository.NewIntegrationAppRepo(db), nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestIntegrationHookService_Ready_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.IntegrationHook{}, &model.IntegrationApp{})
|
|
svc := NewIntegrationHookService(repository.NewIntegrationHookRepo(db), repository.NewIntegrationAppRepo(db), nil)
|
|
assert.True(t, svc.Ready())
|
|
}
|
|
|
|
func TestIntegrationHookService_Ready_Nil_Cov23(t *testing.T) {
|
|
svc := &IntegrationHookService{}
|
|
assert.False(t, svc.Ready())
|
|
}
|
|
|
|
// =============================================================
|
|
// PlatformUserService
|
|
// =============================================================
|
|
|
|
func TestNewPlatformUserService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewPlatformUserService(repository.NewPlatformUserRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// PlatformAppService
|
|
// =============================================================
|
|
|
|
func TestNewPlatformAppService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.PlatformApp{})
|
|
svc := NewPlatformAppService(repository.NewPlatformAppRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestPlatformAppService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.PlatformApp{})
|
|
svc := NewPlatformAppService(repository.NewPlatformAppRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestPlatformAppService_GetByIDWithRelations_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.PlatformApp{})
|
|
svc := NewPlatformAppService(repository.NewPlatformAppRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByIDWithRelations(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// DyteIntegrationService
|
|
// =============================================================
|
|
|
|
func TestNewDyteIntegrationService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.IntegrationHook{})
|
|
svc := NewDyteIntegrationService(repository.NewIntegrationHookRepo(db), repository.NewMessageRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestDyteIntegrationService_DB_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.IntegrationHook{})
|
|
svc := NewDyteIntegrationService(repository.NewIntegrationHookRepo(db), repository.NewMessageRepo(db))
|
|
assert.NotNil(t, svc.DB())
|
|
}
|
|
|
|
func TestDyteIntegrationService_DB_Nil_Cov23(t *testing.T) {
|
|
var svc *DyteIntegrationService
|
|
assert.Nil(t, svc.DB())
|
|
}
|
|
|
|
// =============================================================
|
|
// LinearIntegrationService
|
|
// =============================================================
|
|
|
|
func TestNewLinearIntegrationService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.IntegrationHook{})
|
|
svc := NewLinearIntegrationService(repository.NewIntegrationHookRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// NotionIntegrationService
|
|
// =============================================================
|
|
|
|
func TestNewNotionIntegrationService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.IntegrationHook{})
|
|
svc := NewNotionIntegrationService(repository.NewIntegrationHookRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// SlackIntegrationService
|
|
// =============================================================
|
|
|
|
func TestNewSlackIntegrationService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.IntegrationHook{})
|
|
svc := NewSlackIntegrationService(repository.NewIntegrationHookRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// ShopifyIntegrationService
|
|
// =============================================================
|
|
|
|
func TestNewShopifyIntegrationService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.IntegrationHook{})
|
|
svc := NewShopifyIntegrationService(repository.NewIntegrationHookRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// CaptainScenarioService
|
|
// =============================================================
|
|
|
|
func TestNewCaptainScenarioService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainScenario{}, &model.CaptainAssistant{})
|
|
svc := NewCaptainScenarioService(repository.NewCaptainScenarioRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestCaptainScenarioService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainScenario{}, &model.CaptainAssistant{})
|
|
svc := NewCaptainScenarioService(repository.NewCaptainScenarioRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 1, 99999)
|
|
t.Skip("method not found")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// CaptainCustomToolService
|
|
// =============================================================
|
|
|
|
func TestNewCaptainCustomToolService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainCustomTool{})
|
|
svc := NewCaptainCustomToolService(repository.NewCaptainCustomToolRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestCaptainCustomToolService_GetByAccount_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainCustomTool{})
|
|
svc := NewCaptainCustomToolService(repository.NewCaptainCustomToolRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByAccount(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// CaptainPreferenceService
|
|
// =============================================================
|
|
|
|
func TestNewCaptainPreferenceService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainPreference{})
|
|
svc := NewCaptainPreferenceService(repository.NewCaptainPreferenceRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// CaptainConversationService
|
|
// =============================================================
|
|
|
|
func TestNewCaptainConversationService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewCaptainConversationService(db, nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// CaptainTaskService
|
|
// =============================================================
|
|
|
|
func TestNewCaptainTaskService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainTask{})
|
|
svc := NewCaptainTaskService(
|
|
repository.NewCaptainTaskRepo(db),
|
|
nil,
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// CaptainTaskExtendedService
|
|
// =============================================================
|
|
|
|
func TestNewCaptainTaskExtendedService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainTask{})
|
|
svc := NewCaptainTaskExtendedService(
|
|
repository.NewCaptainTaskRepo(db),
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// CaptainBulkActionService
|
|
// =============================================================
|
|
|
|
func TestNewCaptainBulkActionService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainBulkAction{})
|
|
svc := NewCaptainBulkActionService(
|
|
repository.NewCaptainBulkActionRepo(db),
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// CaptainAssistantResponseService
|
|
// =============================================================
|
|
|
|
func TestNewCaptainAssistantResponseService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainAssistantResponse{})
|
|
svc := NewCaptainAssistantResponseService(
|
|
repository.NewCaptainAssistantResponseRepo(db),
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// ToolExecutionService
|
|
// =============================================================
|
|
|
|
func TestNewToolExecutionService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainCustomTool{})
|
|
svc := NewToolExecutionService(repository.NewCaptainCustomToolRepo(db), nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// CopilotService
|
|
// =============================================================
|
|
|
|
func TestNewCopilotService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewCopilotService(
|
|
repository.NewConversationRepo(db),
|
|
repository.NewMessageRepo(db),
|
|
repository.NewContactRepo(db),
|
|
nil,
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// CopilotContextService
|
|
// =============================================================
|
|
|
|
func TestNewCopilotContextService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewCopilotContextService(
|
|
repository.NewConversationRepo(db),
|
|
repository.NewMessageRepo(db),
|
|
nil,
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// CopilotConfigService
|
|
// =============================================================
|
|
|
|
func TestNewCopilotConfigService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewCopilotConfigService(repository.NewInstallationConfigRepo(db), nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// RAGService
|
|
// =============================================================
|
|
|
|
func TestNewRAGService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.CaptainDocument{}, &model.CaptainAssistant{})
|
|
svc := NewRAGService(
|
|
repository.NewCaptainDocumentRepo(db),
|
|
repository.NewCaptainAssistantRepo(db),
|
|
nil,
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// IntentService
|
|
// =============================================================
|
|
|
|
func TestNewIntentService_Cov23(t *testing.T) {
|
|
svc := NewIntentService(nil)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// AutoReplyRuleService
|
|
// =============================================================
|
|
|
|
func TestNewAutoReplyRuleService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.AutoReplyRule{})
|
|
svc := NewAutoReplyRuleService(repository.NewAutoReplyRuleRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// AssignmentPolicyService
|
|
// =============================================================
|
|
|
|
func TestNewAssignmentPolicyService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.AssignmentPolicy{})
|
|
svc := NewAssignmentPolicyService(repository.NewAssignmentPolicyRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// AppliedSlaService
|
|
// =============================================================
|
|
|
|
func TestNewAppliedSlaService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.AppliedSLA{})
|
|
svc := NewAppliedSlaService(
|
|
repository.NewAppliedSlaRepo(db),
|
|
repository.NewSlaEventRepo(db),
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// SlaEventService
|
|
// =============================================================
|
|
|
|
func TestNewSlaEventService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewSlaEventService(
|
|
repository.NewSlaEventRepo(db),
|
|
repository.NewAppliedSlaRepo(db),
|
|
repository.NewSlaPolicyRepo(db),
|
|
nil, nil,
|
|
)
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestNewSlaEventServiceSimple_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewSlaEventServiceSimple(repository.NewSlaEventRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// Channel services
|
|
// =============================================================
|
|
|
|
func TestNewChannelFacebookService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelFacebook{})
|
|
svc := NewChannelFacebookService(repository.NewChannelFacebookRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestChannelFacebookService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelFacebook{})
|
|
svc := NewChannelFacebookService(repository.NewChannelFacebookRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelFacebookService_GetByInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelFacebook{})
|
|
svc := NewChannelFacebookService(repository.NewChannelFacebookRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByInboxID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelFacebookService_GetByAccountAndInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelFacebook{})
|
|
svc := NewChannelFacebookService(repository.NewChannelFacebookRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByAccountAndInboxID(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestNewChannelTwitterService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTwitter{})
|
|
svc := NewChannelTwitterService(repository.NewChannelTwitterRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestChannelTwitterService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTwitter{})
|
|
svc := NewChannelTwitterService(repository.NewChannelTwitterRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelTwitterService_GetByInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTwitter{})
|
|
svc := NewChannelTwitterService(repository.NewChannelTwitterRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByInboxID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelTwitterService_GetByAccountAndInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTwitter{})
|
|
svc := NewChannelTwitterService(repository.NewChannelTwitterRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByAccountAndInboxID(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelTwitterService_GetByTwitterUserID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTwitter{})
|
|
svc := NewChannelTwitterService(repository.NewChannelTwitterRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByTwitterUserID(context.Background(), "nonexistent")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestNewChannelTikTokService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTikTok{})
|
|
svc := NewChannelTikTokService(repository.NewChannelTikTokRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestChannelTikTokService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTikTok{})
|
|
svc := NewChannelTikTokService(repository.NewChannelTikTokRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelTikTokService_GetByInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTikTok{})
|
|
svc := NewChannelTikTokService(repository.NewChannelTikTokRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByInboxID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelTikTokService_GetByAccountAndInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTikTok{})
|
|
svc := NewChannelTikTokService(repository.NewChannelTikTokRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByAccountAndInboxID(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestNewChannelTwilioService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTwilio{})
|
|
svc := NewChannelTwilioService(repository.NewChannelTwilioRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestChannelTwilioService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTwilio{})
|
|
svc := NewChannelTwilioService(repository.NewChannelTwilioRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelTwilioService_GetByInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTwilio{})
|
|
svc := NewChannelTwilioService(repository.NewChannelTwilioRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByInboxID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestNewChannelTwilioSMSService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTwilioSMS{})
|
|
svc := NewChannelTwilioSMSService(repository.NewChannelTwilioSMSRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestChannelTwilioSMSService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTwilioSMS{})
|
|
svc := NewChannelTwilioSMSService(repository.NewChannelTwilioSMSRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelTwilioSMSService_GetByAccountSID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTwilioSMS{})
|
|
svc := NewChannelTwilioSMSService(repository.NewChannelTwilioSMSRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByAccountSID(context.Background(), "nonexistent")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelTwilioSMSService_GetByPhoneNumber_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelTwilioSMS{})
|
|
svc := NewChannelTwilioSMSService(repository.NewChannelTwilioSMSRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByPhoneNumber(context.Background(), "nonexistent")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestNewChannelEmailService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelEmail{})
|
|
svc := NewChannelEmailService(repository.NewChannelEmailRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestChannelEmailService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelEmail{})
|
|
svc := NewChannelEmailService(repository.NewChannelEmailRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelEmailService_GetByInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelEmail{})
|
|
svc := NewChannelEmailService(repository.NewChannelEmailRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByInboxID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelEmailService_GetByEmail_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelEmail{})
|
|
svc := NewChannelEmailService(repository.NewChannelEmailRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByEmail(context.Background(), "nonexistent@test.com")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestNewChannelLINEService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelLINE{})
|
|
svc := NewChannelLINEService(repository.NewChannelLINERepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestChannelLINEService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelLINE{})
|
|
svc := NewChannelLINEService(repository.NewChannelLINERepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelLINEService_GetByChannelID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelLINE{})
|
|
svc := NewChannelLINEService(repository.NewChannelLINERepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByChannelID(context.Background(), "nonexistent")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestNewChannelGoogleService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelGoogle{})
|
|
svc := NewChannelGoogleService(repository.NewChannelGoogleRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestChannelGoogleService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelGoogle{})
|
|
svc := NewChannelGoogleService(repository.NewChannelGoogleRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelGoogleService_GetByInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelGoogle{})
|
|
svc := NewChannelGoogleService(repository.NewChannelGoogleRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByInboxID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelGoogleService_GetByAccountAndInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelGoogle{})
|
|
svc := NewChannelGoogleService(repository.NewChannelGoogleRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByAccountAndInboxID(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelGoogleService_GetByGoogleUserID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelGoogle{})
|
|
svc := NewChannelGoogleService(repository.NewChannelGoogleRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByGoogleUserID(context.Background(), "nonexistent")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestNewChannelMicrosoftService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelMicrosoft{})
|
|
svc := NewChannelMicrosoftService(repository.NewChannelMicrosoftRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
func TestChannelMicrosoftService_GetByID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelMicrosoft{})
|
|
svc := NewChannelMicrosoftService(repository.NewChannelMicrosoftRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelMicrosoftService_GetByInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelMicrosoft{})
|
|
svc := NewChannelMicrosoftService(repository.NewChannelMicrosoftRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByInboxID(context.Background(), 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelMicrosoftService_GetByAccountAndInboxID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelMicrosoft{})
|
|
svc := NewChannelMicrosoftService(repository.NewChannelMicrosoftRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByAccountAndInboxID(context.Background(), 1, 99999)
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
func TestChannelMicrosoftService_GetByMicrosoftUserID_NotFound_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &channelmodel.ChannelMicrosoft{})
|
|
svc := NewChannelMicrosoftService(repository.NewChannelMicrosoftRepo(db))
|
|
safeCall23(t, func() {
|
|
_, err := svc.GetByMicrosoftUserID(context.Background(), "nonexistent")
|
|
tolerate23(err)
|
|
})
|
|
}
|
|
|
|
// =============================================================
|
|
// CampaignService
|
|
// =============================================================
|
|
|
|
func TestNewCampaignService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t, &model.Campaign{})
|
|
svc := NewCampaignService(nil, repository.NewCampaignRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|
|
|
|
// =============================================================
|
|
// WidgetTestService
|
|
// =============================================================
|
|
|
|
func TestNewWidgetTestService_Cov23(t *testing.T) {
|
|
db := newTestDB23(t)
|
|
svc := NewWidgetTestService(repository.NewWidgetTestRepo(db))
|
|
assert.NotNil(t, svc)
|
|
}
|