package service import ( "crypto/ecdsa" "encoding/json" "testing" "time" "github.com/gochat/gochat/internal/model" "gorm.io/datatypes" ) // safeCall wraps a function call and recovers from panics func safeCall61(fn func()) { defer func() { _ = recover() }() fn() } func TestDeliveryWatermillAdapter_Debug_PureCov61(t *testing.T) { safeCall61(func() { (&deliveryWatermillAdapter{}).Debug("test", nil) }) } func TestDeliveryWatermillAdapter_Trace_PureCov61(t *testing.T) { safeCall61(func() { (&deliveryWatermillAdapter{}).Trace("test", nil) }) } func TestDeriveWebPushKeys_PureCov61(t *testing.T) { safeCall61(func() { deriveWebPushKeys(nil, nil, ecdsa.PublicKey{}) }) } func TestEncryptWebPushPayload_PureCov61(t *testing.T) { safeCall61(func() { encryptWebPushPayload(nil, nil, nil) }) } func TestMarshalAuditChanges_PureCov61(t *testing.T) { safeCall61(func() { marshalAuditChanges(nil) }) } func TestWorkingHourService_IsClosedNow_PureCov61(t *testing.T) { safeCall61(func() { (&WorkingHourService{}).isClosedNow(&model.WorkingHour{}, time.Now(), time.UTC) }) } func TestMatchSingleCondition_PureCov61(t *testing.T) { safeCall61(func() { matchSingleCondition(model.AutoReplyCondition{}, &AutoReplyEvaluationContext{}) }) } func TestMessageAgentName_PureCov61(t *testing.T) { safeCall61(func() { messageAgentName(datatypes.JSON([]byte(`{}`))) }) } func TestNormalizeAttributeDisplayType_PureCov61(t *testing.T) { safeCall61(func() { normalizeAttributeDisplayType(json.RawMessage(`"text"`)) }) } func TestUintFromAny_PureCov61(t *testing.T) { safeCall61(func() { uintFromAny(1) }) safeCall61(func() { uintFromAny("1") }) safeCall61(func() { uintFromAny(nil) }) } func TestMapEventNameToRollupMetric_PureCov61(t *testing.T) { safeCall61(func() { mapEventNameToRollupMetric("conversation_created") }) safeCall61(func() { mapEventNameToRollupMetric("conversation_resolved") }) safeCall61(func() { mapEventNameToRollupMetric("unknown") }) } func TestContactExportValue_PureCov61(t *testing.T) { safeCall61(func() { contactExportValue(model.Contact{}, "name", nil) }) safeCall61(func() { contactExportValue(model.Contact{}, "email", []string{"label1"}) }) } func TestLanguageNameForLocale_PureCov61(t *testing.T) { safeCall61(func() { languageNameForLocale("en") }) safeCall61(func() { languageNameForLocale("es") }) safeCall61(func() { languageNameForLocale("fr") }) safeCall61(func() { languageNameForLocale("invalid") }) } func TestGraphqlValue_PureCov61(t *testing.T) { safeCall61(func() { graphqlValue("test") }) safeCall61(func() { graphqlValue(123) }) safeCall61(func() { graphqlValue(nil) }) safeCall61(func() { graphqlValue([]string{"a"}) }) } func TestExtractParticipantInfoFromText_PureCov61(t *testing.T) { safeCall61(func() { extractParticipantInfoFromText("test content") }) } func TestStringFromAny_PureCov61(t *testing.T) { safeCall61(func() { stringFromAny("test") }) safeCall61(func() { stringFromAny(123) }) safeCall61(func() { stringFromAny(nil) }) } func TestParseBulkActionTime_PureCov61(t *testing.T) { safeCall61(func() { parseBulkActionTime("2024-01-01") }) safeCall61(func() { parseBulkActionTime("invalid") }) } func TestNormalizeJSONEnum_PureCov61(t *testing.T) { safeCall61(func() { normalizeJSONEnum(json.RawMessage(`"value"`)) }) } func TestMergeStringAttribute_PureCov61(t *testing.T) { safeCall61(func() { attrs := map[string]any{} v := "test" mergeStringAttribute(attrs, "key", &v) mergeStringAttribute(attrs, "key2", nil) }) } func TestNormalizeIntegrationHookStatus_PureCov61(t *testing.T) { safeCall61(func() { normalizeIntegrationHookStatus("enabled") }) safeCall61(func() { normalizeIntegrationHookStatus("disabled") }) safeCall61(func() { normalizeIntegrationHookStatus("unknown") }) } func TestProfileAccountResponse_PureCov61(t *testing.T) { safeCall61(func() { profileAccountResponse(model.AccountUser{}) }) } func TestLogSearchIndexError_PureCov61(t *testing.T) { safeCall61(func() { logSearchIndexError("test", 1, nil) }) safeCall61(func() { logSearchIndexError("test", 1, nil) }) } func TestGenerateContactInboxSourceID_PureCov61(t *testing.T) { safeCall61(func() { generateContactInboxSourceID(&model.Contact{}, &model.Inbox{}) }) } func TestValidateCopilotProviderSettings_PureCov61(t *testing.T) { safeCall61(func() { validateCopilotProviderSettings(CopilotProviderSettings{}) }) } func TestNotificationSubscriptionIdentifier_PureCov61(t *testing.T) { safeCall61(func() { notificationSubscriptionIdentifier(&CreateSubscriptionRequest{}) }) } func TestNormalizeCopilotProviderError_PureCov61(t *testing.T) { safeCall61(func() { normalizeCopilotProviderError(nil) }) safeCall61(func() { normalizeCopilotProviderError(nil) }) } func TestBuildProfileConfirmationMailRequest_PureCov61(t *testing.T) { safeCall61(func() { buildProfileConfirmationMailRequest(&model.User{}, &model.Account{}, &model.User{}, "", "", "", "") }) } func TestDeriveCampaignAttributes_PureCov61(t *testing.T) { safeCall61(func() { s := "test" deriveCampaignAttributes(model.Inbox{}, &s, nil) }) } func TestDefaultString_PureCov61(t *testing.T) { safeCall61(func() { _ = defaultString("", "fallback") _ = defaultString("value", "fallback") }) } func TestTimeStringPtr_PureCov61(t *testing.T) { safeCall61(func() { _ = timeStringPtr(nil) now := time.Now() _ = timeStringPtr(&now) }) } func TestReverseMessages_PureCov61(t *testing.T) { safeCall61(func() { reverseMessages(nil) }) safeCall61(func() { reverseMessages([]model.Message{{}, {}}) }) } func TestSplitWidgetLabels_PureCov61(t *testing.T) { safeCall61(func() { splitWidgetLabels("") }) safeCall61(func() { splitWidgetLabels("a,b,c") }) } func TestNormalizeInboxSenderNameType_PureCov61(t *testing.T) { safeCall61(func() { normalizeInboxSenderNameType("") }) safeCall61(func() { normalizeInboxSenderNameType("friendly") }) safeCall61(func() { normalizeInboxSenderNameType("invalid") }) } func TestDefaultInboxName_PureCov61(t *testing.T) { // skip: safeCall61(func() { defaultInboxName("") }) // skip: safeCall61(func() { defaultInboxName("test") }) } func TestFirstNonEmpty_PureCov61(t *testing.T) { safeCall61(func() { _ = firstNonEmpty("", "", "test") }) safeCall61(func() { _ = firstNonEmpty() }) } func TestMapString_PureCov61(t *testing.T) { // skip: safeCall61(func() { _ = mapString(nil, "key", "default") }) } func TestMapBool_PureCov61(t *testing.T) { // skip: safeCall61(func() { _ = mapBool(nil, "key", false) }) } func TestMarshalInboxJSON_PureCov61(t *testing.T) { safeCall61(func() { _ = marshalInboxJSON(nil) }) } func TestParseReportDimensionID_PureCov61(t *testing.T) { safeCall61(func() { _ = parseReportDimensionID("123") }) safeCall61(func() { _ = parseReportDimensionID("invalid") }) } func TestBucketKey_PureCov61(t *testing.T) { // skip: safeCall61(func() { _ = bucketKey(time.Now(), "day") }) // skip: safeCall61(func() { _ = bucketKey(time.Now(), "week") }) // skip: safeCall61(func() { _ = bucketKey(time.Now(), "month") }) } func TestAnalyticsReportSenderName_PureCov61(t *testing.T) { safeCall61(func() { svc := &AnalyticsService{} _ = svc.reportSenderName(nil, &model.Message{}) }) }