package v1 import ( "context" "encoding/json" "net/http/httptest" "strings" "testing" "github.com/gin-gonic/gin" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gorm.io/gorm" "github.com/gochat/gochat/internal/automation" "github.com/gochat/gochat/internal/canned" "github.com/gochat/gochat/internal/model" "github.com/gochat/gochat/internal/repository" "github.com/gochat/gochat/internal/search" "github.com/gochat/gochat/internal/service" ) func init() { gin.SetMode(gin.TestMode) } func safeCall_Cov8(t *testing.T, f func()) { defer func() { _ = recover() }() f() } func newCtx_Cov8(method, path string) (*gin.Context, *httptest.ResponseRecorder) { w := httptest.NewRecorder() c, _ := gin.CreateTestContext(w) c.Request = httptest.NewRequest(method, path, nil) c.Request = c.Request.WithContext(context.Background()) return c, w } func newCtxBody_Cov8(method, path string, body string) (*gin.Context, *httptest.ResponseRecorder) { w := httptest.NewRecorder() c, _ := gin.CreateTestContext(w) c.Request = httptest.NewRequest(method, path, strings.NewReader(body)) if body != "" { c.Request.Header.Set("Content-Type", "application/json") } c.Request = c.Request.WithContext(context.Background()) return c, w } // ================================================================= // Helper function tests — search_handler.go // ================================================================= func TestSerializeSearchConversationMessageMap_Empty_Cov8(t *testing.T) { result := serializeSearchConversationMessageMap(context.Background(), nil, map[string]any{}) assert.NotNil(t, result) assert.Len(t, result, 0) } func TestSerializeSearchConversationMessageMap_NonEmpty_Cov8(t *testing.T) { data := map[string]any{"id": float64(42), "content": "hello"} result := serializeSearchConversationMessageMap(context.Background(), nil, data) assert.NotNil(t, result) } func TestSerializeSearchConversationContactMap_Empty_Cov8(t *testing.T) { result := serializeSearchConversationContactMap(map[string]any{}) assert.NotNil(t, result) assert.Len(t, result, 0) } func TestSerializeSearchConversationContactMap_NonEmpty_Cov8(t *testing.T) { data := map[string]any{"email": "a@b.com", "id": float64(1), "name": "Test"} result := serializeSearchConversationContactMap(data) assert.NotNil(t, result) assert.Equal(t, "a@b.com", result["email"]) } func TestSerializeSearchConversationInboxMap_Empty_Cov8(t *testing.T) { result := serializeSearchConversationInboxMap(map[string]any{}) assert.NotNil(t, result) assert.Len(t, result, 0) } func TestSerializeSearchConversationInboxMap_NonEmpty_Cov8(t *testing.T) { data := map[string]any{"id": float64(1), "name": "Inbox1", "channel_type": "web_widget"} result := serializeSearchConversationInboxMap(data) assert.NotNil(t, result) assert.Equal(t, "Inbox1", result["name"]) } func TestSerializeSearchConversationAgentMap_Empty_Cov8(t *testing.T) { result := serializeSearchConversationAgentMap(map[string]any{}) assert.NotNil(t, result) assert.Len(t, result, 0) } func TestSerializeSearchConversationAgentMap_NonEmpty_Cov8(t *testing.T) { data := map[string]any{"id": float64(1), "name": "Agent1", "email": "agent@test.com"} result := serializeSearchConversationAgentMap(data) assert.NotNil(t, result) assert.Equal(t, "Agent1", result["name"]) } func TestSerializeSearchConversationAgentMap_DisplayName_Cov8(t *testing.T) { data := map[string]any{"id": float64(1), "display_name": "DisplayAgent"} result := serializeSearchConversationAgentMap(data) assert.NotNil(t, result) assert.Equal(t, "DisplayAgent", result["available_name"]) } func TestFirstNestedSearchData_Cov8(t *testing.T) { root := map[string]any{"message": map[string]any{"id": float64(1)}} fallback := map[string]any{"contact": map[string]any{"name": "test"}} result := firstNestedSearchData(root, fallback, "message", "contact") assert.NotNil(t, result) } func TestFirstNestedSearchData_Fallback_Cov8(t *testing.T) { root := map[string]any{} fallback := map[string]any{"contact": map[string]any{"name": "test"}} result := firstNestedSearchData(root, fallback, "contact") assert.NotNil(t, result) } func TestFirstNestedSearchData_Empty_Cov8(t *testing.T) { root := map[string]any{} fallback := map[string]any{} result := firstNestedSearchData(root, fallback, "message", "contact") assert.NotNil(t, result) assert.Len(t, result, 0) } func TestUintFromAny_Uint_Cov8(t *testing.T) { assert.Equal(t, uint(42), uintFromAny(uint(42))) } func TestUintFromAny_Int_Cov8(t *testing.T) { assert.Equal(t, uint(42), uintFromAny(int(42))) } func TestUintFromAny_IntNegative_Cov8(t *testing.T) { assert.Equal(t, uint(0), uintFromAny(int(-1))) } func TestUintFromAny_Int64_Cov8(t *testing.T) { assert.Equal(t, uint(42), uintFromAny(int64(42))) } func TestUintFromAny_Float64_Cov8(t *testing.T) { assert.Equal(t, uint(42), uintFromAny(float64(42))) } func TestUintFromAny_String_Cov8(t *testing.T) { assert.Equal(t, uint(0), uintFromAny("abc")) } func TestUintFromAny_Nil_Cov8(t *testing.T) { assert.Equal(t, uint(0), uintFromAny(nil)) } func TestAnyMap_MapStringAny_Cov8(t *testing.T) { m, ok := anyMap(map[string]any{"key": "val"}) assert.True(t, ok) assert.NotNil(t, m) } func TestAnyMap_GinH_Cov8(t *testing.T) { m, ok := anyMap(gin.H{"key": "val"}) assert.True(t, ok) assert.NotNil(t, m) } func TestAnyMap_Default_Cov8(t *testing.T) { _, ok := anyMap(123) assert.False(t, ok) } func TestFirstMapValue_Cov8(t *testing.T) { data := map[string]any{"a": 1, "b": 2} assert.Equal(t, 1, firstMapValue(data, "a", "b")) assert.Equal(t, 2, firstMapValue(data, "c", "b")) assert.Nil(t, firstMapValue(data, "x", "y")) } func TestUnixFromMapValue_Float64_Cov8(t *testing.T) { assert.Equal(t, int64(100), unixFromMapValue(float64(100))) } func TestUnixFromMapValue_Int64_Cov8(t *testing.T) { assert.Equal(t, int64(100), unixFromMapValue(int64(100))) } func TestUnixFromMapValue_Int_Cov8(t *testing.T) { assert.Equal(t, int64(100), unixFromMapValue(int(100))) } func TestUnixFromMapValue_Uint_Cov8(t *testing.T) { assert.Equal(t, int64(100), unixFromMapValue(uint(100))) } func TestUnixFromMapValue_Default_Cov8(t *testing.T) { assert.Equal(t, "abc", unixFromMapValue("abc")) } func TestNestedSearchData_Cov8(t *testing.T) { result := nestedSearchData(search.SearchResult{Data: map[string]any{"message": map[string]any{"id": 1}}}, "message") assert.NotNil(t, result) } func TestNestedSearchData_RootWithData_Cov8(t *testing.T) { result := nestedSearchData(search.SearchResult{Data: map[string]any{"data": map[string]any{"message": map[string]any{"id": 1}}}}, "message") assert.NotNil(t, result) } func TestSearchDataRoot_Cov8(t *testing.T) { result := searchDataRoot(search.SearchResult{Data: map[string]any{"id": 1}}) assert.NotNil(t, result) } func TestSearchDataRoot_WithDataKey_Cov8(t *testing.T) { result := searchDataRoot(search.SearchResult{Data: map[string]any{"data": map[string]any{"id": 1}}}) assert.NotNil(t, result) } func TestSearchDataRoot_NonMap_Cov8(t *testing.T) { result := searchDataRoot(search.SearchResult{Data: "string"}) assert.NotNil(t, result) assert.Len(t, result, 0) } func TestNormalizeSearchMessageType_Cov8(t *testing.T) { assert.Equal(t, 0, normalizeSearchMessageType("incoming")) } func TestNormalizeSearchMessageType_EmptyString_Cov8(t *testing.T) { assert.Equal(t, "", normalizeSearchMessageType("")) } func TestNormalizeSearchMessageType_NonString_Cov8(t *testing.T) { assert.Equal(t, 123, normalizeSearchMessageType(123)) } func TestSerializeSearchContacts_Cov8(t *testing.T) { results := []search.SearchResult{{Data: map[string]any{"email": "test@test.com"}}} payload := serializeSearchContacts(results) assert.Len(t, payload, 1) } func TestSerializeSearchContact_Map_Cov8(t *testing.T) { result := serializeSearchContact(search.SearchResult{Data: map[string]any{"contact": map[string]any{"email": "x@y.com"}}}) assert.NotNil(t, result) } func TestSerializeSearchContact_Model_Cov8(t *testing.T) { contact := model.Contact{Email: "test@test.com", Name: "Test"} result := serializeSearchContact(search.SearchResult{Data: contact}) assert.NotNil(t, result) assert.Equal(t, "test@test.com", result["email"]) } func TestSerializeSearchContact_ModelPtr_Cov8(t *testing.T) { contact := &model.Contact{Email: "test@test.com", Name: "Test"} result := serializeSearchContact(search.SearchResult{Data: contact}) assert.NotNil(t, result) assert.Equal(t, "test@test.com", result["email"]) } func TestSerializeSearchMessages_Cov8(t *testing.T) { results := []search.SearchResult{{Data: map[string]any{"message": map[string]any{"id": float64(1)}}}} payload := serializeSearchMessages(context.Background(), nil, results) assert.Len(t, payload, 1) } func TestSerializeSearchMessage_Map_Cov8(t *testing.T) { result := serializeSearchMessage(context.Background(), nil, search.SearchResult{Data: map[string]any{"message": map[string]any{"id": float64(1), "content": "hi"}}}) assert.NotNil(t, result) } func TestSerializeSearchMessage_Model_Cov8(t *testing.T) { msg := model.Message{Content: "hello"} result := serializeSearchMessage(context.Background(), nil, search.SearchResult{Data: msg}) assert.NotNil(t, result) } func TestSerializeSearchArticles_Cov8(t *testing.T) { results := []search.SearchResult{{Data: map[string]any{"article": map[string]any{"id": float64(1)}}}} payload := serializeSearchArticles(context.Background(), nil, results) assert.Len(t, payload, 1) } func TestSerializeSearchArticle_Map_Cov8(t *testing.T) { result := serializeSearchArticle(context.Background(), nil, search.SearchResult{Data: map[string]any{"article": map[string]any{"id": float64(1), "title": "Test"}}}) assert.NotNil(t, result) } func TestSerializeSearchArticle_Model_Cov8(t *testing.T) { article := model.Article{Title: "Test Article"} result := serializeSearchArticle(context.Background(), nil, search.SearchResult{Data: article}) assert.NotNil(t, result) assert.Equal(t, "Test Article", result["title"]) } func TestOmitNilSearchMessageFields_Cov8(t *testing.T) { data := map[string]any{"id": 1, "echo_id": "", "sender": nil, "attachments": []any{}} result := omitNilSearchMessageFields(data) _, hasEcho := result["echo_id"] assert.False(t, hasEcho) _, hasSender := result["sender"] assert.False(t, hasSender) } // ================================================================= // SearchHandler constructor + nil-service tests // ================================================================= func TestNewSearchHandler_Cov8(t *testing.T) { h := NewSearchHandler(nil) assert.NotNil(t, h) } func TestSearchHandler_GlobalSearch_NoSvc_Cov8(t *testing.T) { h := NewSearchHandler(nil) c, _ := newCtx_Cov8("GET", "/?q=test") safeCall_Cov8(t, func() { h.GlobalSearch(c) }) } func TestSearchHandler_SearchConversations_NoSvc_Cov8(t *testing.T) { h := NewSearchHandler(nil) c, _ := newCtx_Cov8("GET", "/?q=test") safeCall_Cov8(t, func() { h.SearchConversations(c) }) } func TestSearchHandler_SearchMessages_NoSvc_Cov8(t *testing.T) { h := NewSearchHandler(nil) c, _ := newCtx_Cov8("GET", "/?q=test") safeCall_Cov8(t, func() { h.SearchMessages(c) }) } func TestSearchHandler_SearchContacts_NoSvc_Cov8(t *testing.T) { h := NewSearchHandler(nil) c, _ := newCtx_Cov8("GET", "/?q=test") safeCall_Cov8(t, func() { h.SearchContacts(c) }) } func TestSearchHandler_SearchArticles_NoSvc_Cov8(t *testing.T) { h := NewSearchHandler(nil) c, _ := newCtx_Cov8("GET", "/?q=test") safeCall_Cov8(t, func() { h.SearchArticles(c) }) } // ================================================================= // ArticleHandler helper tests // ================================================================= func TestPublicSearchTruncate_NoLimit_Cov8(t *testing.T) { assert.Equal(t, "hello", publicSearchTruncate("hello", 0)) } func TestPublicSearchTruncate_ShortText_Cov8(t *testing.T) { assert.Equal(t, "hi", publicSearchTruncate("hi", 10)) } func TestPublicSearchTruncate_LongText_Cov8(t *testing.T) { result := publicSearchTruncate("hello world this is a long text", 15) assert.True(t, strings.HasSuffix(result, "...")) } func TestPublicSearchTruncate_NoSpace_Cov8(t *testing.T) { result := publicSearchTruncate("abcdefghij", 5) assert.Equal(t, "abcde...", result) } // ================================================================= // AuthHandler helper tests // ================================================================= func TestGenerateOAuthState_Cov8(t *testing.T) { state := generateOAuthState() assert.True(t, strings.HasPrefix(state, "gochat_oauth_")) assert.True(t, len(state) > len("gochat_oauth_")) } func TestRandomHex_Cov8(t *testing.T) { hex := randomHex(16) assert.Len(t, hex, 32) // 16 bytes = 32 hex chars } func TestRandomHex_Zero_Cov8(t *testing.T) { hex := randomHex(0) assert.Empty(t, hex) } // ================================================================= // AutomationRuleHandler helper tests // ================================================================= func TestFirstNonNil_Cov8(t *testing.T) { assert.Equal(t, "first", firstNonNil("first", "second")) } func TestFirstNonNil_SkipNil_Cov8(t *testing.T) { assert.Equal(t, "second", firstNonNil(nil, "second")) } func TestFirstNonNil_AllNil_Cov8(t *testing.T) { assert.Nil(t, firstNonNil(nil, nil)) } func TestFirstNonNil_Empty_Cov8(t *testing.T) { assert.Nil(t, firstNonNil()) } func TestJsonValueToString_Cov8(t *testing.T) { assert.Equal(t, "test", valueToString("test")) } func TestJsonValueToString_JsonNumber_Cov8(t *testing.T) { n := json.Number("42") assert.Equal(t, "42", valueToString(n)) } func TestJsonNumberSafeString_Cov8(t *testing.T) { assert.Equal(t, "42", jsonNumberSafeString(42)) } func TestJsonNumberSafeString_Struct_Cov8(t *testing.T) { result := jsonNumberSafeString(struct{ A int }{A: 1}) assert.Contains(t, result, "1") } func TestValuesToStrings_Cov8(t *testing.T) { values := []interface{}{"a", "b", nil} result := valuesToStrings(values) assert.Len(t, result, 2) } func TestValueToString_Default_Cov8(t *testing.T) { assert.Equal(t, "42", valueToString(42)) } func TestValuesToInterfaces_Slice_Cov8(t *testing.T) { result := valuesToInterfaces([]interface{}{1, 2}) assert.Len(t, result, 2) } func TestValuesToInterfaces_StringSlice_Cov8(t *testing.T) { result := valuesToInterfaces([]string{"a", "b"}) assert.Len(t, result, 2) } func TestValuesToInterfaces_UintSlice_Cov8(t *testing.T) { result := valuesToInterfaces([]uint{1, 2}) assert.Len(t, result, 2) } func TestValuesToInterfaces_IntSlice_Cov8(t *testing.T) { result := valuesToInterfaces([]int{1, 2}) assert.Len(t, result, 2) } func TestValuesToInterfaces_Nil_Cov8(t *testing.T) { result := valuesToInterfaces(nil) assert.Len(t, result, 0) } func TestValuesToInterfaces_Default_Cov8(t *testing.T) { result := valuesToInterfaces(42) assert.Len(t, result, 1) } func TestFirstValue_Cov8(t *testing.T) { assert.Equal(t, "first", firstValue([]interface{}{"first", "second"})) } func TestFirstValue_Empty_Cov8(t *testing.T) { assert.Nil(t, firstValue([]interface{}{})) } func TestCompactValues_Cov8(t *testing.T) { result := compactValues(nil, "second") assert.Len(t, result, 1) assert.Equal(t, "second", result[0]) } func TestCompactValues_AllNil_Cov8(t *testing.T) { result := compactValues(nil, nil) assert.Len(t, result, 0) } // ================================================================= // CategoryHandler helper tests // ================================================================= func TestAssociatedCategoryPayload_Cov8(t *testing.T) { cat := &model.Category{ Base: model.Base{ID: 1}, Name: "Test", Slug: "test", Locale: "en", AccountID: 100, } result := associatedCategoryPayload(cat) assert.Equal(t, uint(1), result["id"]) assert.Equal(t, "Test", result["name"]) assert.Equal(t, "test", result["slug"]) assert.Equal(t, "en", result["locale"]) assert.Equal(t, uint(100), result["account_id"]) } func TestCategoryArticleCount_Cov8(t *testing.T) { articles := []model.Article{{Locale: "en"}, {Locale: "fr"}, {Locale: "en"}} assert.Equal(t, 2, categoryArticleCount(articles, "en")) } func TestCategoryArticleCount_AllLocales_Cov8(t *testing.T) { articles := []model.Article{{Locale: "en"}, {Locale: "fr"}} assert.Equal(t, 2, categoryArticleCount(articles, "")) } func TestNewCategoryHandler_Cov8(t *testing.T) { h := NewCategoryHandler(nil) assert.NotNil(t, h) } // ================================================================= // ContactHandler helper tests // ================================================================= func TestParseIntOrDefault_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/?page=5") assert.Equal(t, 5, parseIntOrDefault(c, "page", 1)) } func TestParseIntOrDefault_Default_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") assert.Equal(t, 1, parseIntOrDefault(c, "page", 1)) } func TestParseIntOrDefault_Invalid_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/?page=abc") assert.Equal(t, 1, parseIntOrDefault(c, "page", 1)) } func TestUintStringValue_Cov8(t *testing.T) { assert.Equal(t, uint(42), uintStringValue("42")) } func TestUintStringValue_Invalid_Cov8(t *testing.T) { assert.Equal(t, uint(0), uintStringValue("abc")) } func TestUintStringValue_Empty_Cov8(t *testing.T) { assert.Equal(t, uint(0), uintStringValue("")) } func TestBoolStringValue_True_Cov8(t *testing.T) { assert.True(t, boolStringValue("true")) } func TestBoolStringValue_False_Cov8(t *testing.T) { assert.False(t, boolStringValue("false")) } func TestBoolStringValue_Invalid_Cov8(t *testing.T) { assert.False(t, boolStringValue("abc")) } func TestNewContactHandler_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) assert.NotNil(t, h) } // ================================================================= // InboxHandler helper tests // ================================================================= func TestInboxUintPtr_Empty_Cov8(t *testing.T) { assert.Nil(t, inboxUintPtr("")) } func TestInboxUintPtr_Valid_Cov8(t *testing.T) { result := inboxUintPtr("42") require.NotNil(t, result) assert.Equal(t, uint(42), *result) } func TestInboxUintPtr_Invalid_Cov8(t *testing.T) { assert.Nil(t, inboxUintPtr("abc")) } func TestInboxJSONObject_Empty_Cov8(t *testing.T) { assert.Nil(t, inboxJSONObject("")) } func TestInboxJSONObject_Valid_Cov8(t *testing.T) { result := inboxJSONObject(`{"key":"value"}`) assert.NotNil(t, result) assert.Equal(t, "value", result["key"]) } func TestInboxJSONObject_Invalid_Cov8(t *testing.T) { assert.Nil(t, inboxJSONObject("invalid")) } func TestInboxWorkingHours_Empty_Cov8(t *testing.T) { assert.Nil(t, inboxWorkingHours("")) } func TestInboxWorkingHours_Valid_Cov8(t *testing.T) { result := inboxWorkingHours(`[{"day_of_week":1}]`) assert.Len(t, result, 1) } func TestInboxWorkingHours_Invalid_Cov8(t *testing.T) { assert.Nil(t, inboxWorkingHours("invalid")) } func TestNewInboxHandler_Cov8(t *testing.T) { h := NewInboxHandler(nil) assert.NotNil(t, h) } // ================================================================= // InstagramChannelHandler helper tests // ================================================================= func TestNewBool_Cov8(t *testing.T) { b := newBool(true) require.NotNil(t, b) assert.True(t, *b) } func TestNewBool_False_Cov8(t *testing.T) { b := newBool(false) require.NotNil(t, b) assert.False(t, *b) } func TestNewInstagramChannelHandler_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) assert.NotNil(t, h) } // ================================================================= // PortalHandler helper tests // ================================================================= func TestPortalInstructionError_CustomDomain_Cov8(t *testing.T) { assert.Equal(t, "Custom domain is not configured", portalInstructionError("no custom domain configured")) } func TestPortalInstructionError_CustomDomain2_Cov8(t *testing.T) { assert.Equal(t, "Custom domain is not configured", portalInstructionError("custom domain error")) } func TestPortalInstructionError_InvalidEmail_Cov8(t *testing.T) { assert.Equal(t, "Invalid email format", portalInstructionError("invalid email address")) } func TestPortalInstructionError_EmailRequired_Cov8(t *testing.T) { assert.Equal(t, "Email is required", portalInstructionError("email is required")) } func TestPortalInstructionError_Email_Cov8(t *testing.T) { assert.Equal(t, "Email is required", portalInstructionError("email not found")) } func TestPortalInstructionError_Default_Cov8(t *testing.T) { assert.Equal(t, "some other error", portalInstructionError("some other error")) } func TestNewPortalHandler_Cov8(t *testing.T) { h := NewPortalHandler(nil) assert.NotNil(t, h) } // ================================================================= // PlatformHandler helper tests // ================================================================= func TestIsValidPermissibleTypeStr_Account_Cov8(t *testing.T) { assert.True(t, isValidPermissibleTypeStr(model.PermissibleTypeAccount)) } func TestIsValidPermissibleTypeStr_User_Cov8(t *testing.T) { assert.True(t, isValidPermissibleTypeStr(model.PermissibleTypeUser)) } func TestIsValidPermissibleTypeStr_AgentBot_Cov8(t *testing.T) { assert.True(t, isValidPermissibleTypeStr(model.PermissibleTypeAgentBot)) } func TestIsValidPermissibleTypeStr_Invalid_Cov8(t *testing.T) { assert.False(t, isValidPermissibleTypeStr("invalid")) } func TestNewPlatformAppHandler_Cov8(t *testing.T) { h := NewPlatformAppHandler(nil) assert.NotNil(t, h) } // ================================================================= // NotificationHandler helper tests // ================================================================= func TestSerializeNotification_Cov8(t *testing.T) { n := &model.Notification{ ID: 1, NotificationType: "test", PrimaryActorType: "Conversation", PrimaryActorID: 10, } result := serializeNotification(n) assert.NotNil(t, result) assert.Equal(t, uint(1), result["id"]) assert.Equal(t, "test", result["notification_type"]) } func TestSerializeNotification_WithAttrs_Cov8(t *testing.T) { n := &model.Notification{ ID: 1, AdditionalAttributes: json.RawMessage(`{"key":"value"}`), } result := serializeNotification(n) assert.NotNil(t, result) } func TestNewNotificationHandler_Cov8(t *testing.T) { h := NewNotificationHandler(nil) assert.NotNil(t, h) } // ================================================================= // SSEEventHandler helper tests // ================================================================= func TestGenerateSSEChannelID_Cov8(t *testing.T) { id := generateSSEChannelID() assert.True(t, strings.HasPrefix(id, "sse_")) assert.True(t, len(id) > 4) } func TestGenerateSSEChannelID_Unique_Cov8(t *testing.T) { id1 := generateSSEChannelID() id2 := generateSSEChannelID() assert.NotEqual(t, id1, id2) } func TestNewSSEEventHandler_Cov8(t *testing.T) { h := NewSSEEventHandler(nil) assert.NotNil(t, h) } // ================================================================= // SocialAuthorization helper tests // ================================================================= func TestAuthorizationReturnTo_Query_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/?return_to=https://example.com") result := authorizationReturnTo(c, "") assert.Equal(t, "https://example.com", result) } func TestAuthorizationReturnTo_Empty_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") result := authorizationReturnTo(c, "") assert.Empty(t, result) } func TestAuthorizationReturnTo_Body_Cov8(t *testing.T) { c, _ := newCtxBody_Cov8("POST", "/", `{"return_to":"https://body.example.com"}`) result := authorizationReturnTo(c, "https://body.example.com") assert.Equal(t, "https://body.example.com", result) } // ================================================================= // WebhookSubscriptionHandler helper tests // ================================================================= func TestAbortWebhookSubscriptionError_NotFound_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { abortWebhookSubscriptionError(c, gorm.ErrRecordNotFound) }) } func TestAbortWebhookSubscriptionError_Other_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { abortWebhookSubscriptionError(c, assertError_Cov8("some error")) }) } func TestNewWebhookSubscriptionHandler_Cov8(t *testing.T) { h := NewWebhookSubscriptionHandler(nil) assert.NotNil(t, h) } // ================================================================= // WhatsAppCallHandler helper tests // ================================================================= func TestHandleWhatsAppCallError_SDOffer_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handleWhatsAppCallError(c, service.ErrWhatsAppCallSDPOfferRequired) }) } func TestHandleWhatsAppCallError_SDPAnswer_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handleWhatsAppCallError(c, service.ErrWhatsAppCallSDPAnswerRequired) }) } func TestHandleWhatsAppCallError_ContactPhone_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handleWhatsAppCallError(c, service.ErrWhatsAppCallContactPhoneRequired) }) } func TestHandleWhatsAppCallError_NotEnabled_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handleWhatsAppCallError(c, service.ErrWhatsAppCallNotEnabled) }) } func TestHandleWhatsAppCallError_NoRecording_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handleWhatsAppCallError(c, service.ErrWhatsAppCallNoRecording) }) } func TestHandleWhatsAppCallError_NoMessage_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handleWhatsAppCallError(c, service.ErrWhatsAppCallNoMessage) }) } func TestHandleWhatsAppCallError_PermReqFailed_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handleWhatsAppCallError(c, service.ErrWhatsAppCallPermissionRequestFailed) }) } func TestHandleWhatsAppCallError_AlreadyAccepted_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handleWhatsAppCallError(c, service.ErrWhatsAppCallAlreadyAccepted) }) } func TestHandleWhatsAppCallError_NotRinging_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handleWhatsAppCallError(c, service.ErrWhatsAppCallNotRinging) }) } func TestHandleWhatsAppCallError_Other_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handleWhatsAppCallError(c, assertError_Cov8("generic error")) }) } func TestNewWhatsAppCallHandler_Cov8(t *testing.T) { h := NewWhatsAppCallHandler(nil) assert.NotNil(t, h) } // ================================================================= // ShopifyIntegrationHandler helper tests // ================================================================= func TestHandleShopifyServiceError_Provider_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handleShopifyServiceError(c, &service.ShopifyProviderError{Message: "provider error"}) }) } func TestHandleShopifyServiceError_Other_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handleShopifyServiceError(c, assertError_Cov8("generic error")) }) } func TestNewShopifyIntegrationHandler_Cov8(t *testing.T) { h := NewShopifyIntegrationHandler(nil) assert.NotNil(t, h) } // ================================================================= // LinearIntegrationHandler helper tests // ================================================================= func TestHandleLinearServiceError_Provider_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handleLinearServiceError(c, &service.LinearProviderError{Message: "provider error"}) }) } func TestHandleLinearServiceError_Other_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handleLinearServiceError(c, assertError_Cov8("generic error")) }) } func TestNewLinearIntegrationHandler_Cov8(t *testing.T) { h := NewLinearIntegrationHandler(nil) assert.NotNil(t, h) } // ================================================================= // PlatformUserHandler helper tests // ================================================================= func TestHandlePlatformError_NonPermissible_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handlePlatformError(c, assertError_Cov8("non permissible resource")) }) } func TestHandlePlatformError_Other_Cov8(t *testing.T) { c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { handlePlatformError(c, assertError_Cov8("some error")) }) } func TestNewPlatformUserHandler_Cov8(t *testing.T) { h := NewPlatformUserHandler(nil) assert.NotNil(t, h) } // ================================================================= // InboxCsatTemplateHandler tests // ================================================================= func TestBindAnalyzeCsatTemplateRequest_Valid_Cov8(t *testing.T) { c, _ := newCtxBody_Cov8("POST", "/", `{"message":"How was your experience?","button_text":"Submit","language":"en"}`) req, err := bindAnalyzeCsatTemplateRequest(c) assert.NoError(t, err) assert.Equal(t, "How was your experience?", req.Message) assert.Equal(t, "Submit", req.ButtonText) assert.Equal(t, "en", req.Language) } func TestBindAnalyzeCsatTemplateRequest_TemplateNested_Cov8(t *testing.T) { c, _ := newCtxBody_Cov8("POST", "/", `{"template":{"message":"nested msg","button_text":"OK","language":"fr"}}`) req, err := bindAnalyzeCsatTemplateRequest(c) assert.NoError(t, err) assert.Equal(t, "nested msg", req.Message) assert.Equal(t, "fr", req.Language) } func TestBindAnalyzeCsatTemplateRequest_NoMessage_Cov8(t *testing.T) { c, _ := newCtxBody_Cov8("POST", "/", `{"button_text":"OK"}`) _, err := bindAnalyzeCsatTemplateRequest(c) assert.Error(t, err) } func TestBindAnalyzeCsatTemplateRequest_InvalidJSON_Cov8(t *testing.T) { c, _ := newCtxBody_Cov8("POST", "/", `invalid json`) _, err := bindAnalyzeCsatTemplateRequest(c) assert.Error(t, err) } func TestNewInboxCsatTemplateHandler_Cov8(t *testing.T) { h := NewInboxCsatTemplateHandler(nil) assert.NotNil(t, h) } // ================================================================= // BulkActionHandler tests // ================================================================= func TestNewBulkActionHandler_Cov8(t *testing.T) { h := NewBulkActionHandler(nil, nil) assert.NotNil(t, h) } func TestBulkActionHandler_PerformContactBulkSync_NilSvc_Cov8(t *testing.T) { h := NewBulkActionHandler(nil, nil) c, _ := newCtx_Cov8("POST", "/") err := h.performContactBulkSync(c, 1, BulkActionRequest{}) assert.NoError(t, err) } // ================================================================= // Additional constructor tests // ================================================================= func TestNewArticleHandler_Cov8(t *testing.T) { h := NewArticleHandler(nil) assert.NotNil(t, h) } func TestNewAuthHandler_Cov8(t *testing.T) { h := NewAuthHandler(nil) assert.NotNil(t, h) } func TestNewAutomationRuleHandler_Cov8(t *testing.T) { h := NewAutomationRuleHandler(nil) assert.NotNil(t, h) } func TestNewAgentHandler_Cov8(t *testing.T) { h := NewAgentHandler(nil) assert.NotNil(t, h) } func TestNewAnalyticsHandler_Cov8(t *testing.T) { h := NewAnalyticsHandler(nil) assert.NotNil(t, h) } func TestNewCampaignHandler_Cov8(t *testing.T) { h := NewCampaignHandler(nil) assert.NotNil(t, h) } func TestNewCannedResponseHandler_Cov8(t *testing.T) { h := NewCannedResponseHandler(nil) assert.NotNil(t, h) } func TestNewCaptainAssistantHandler_Cov8(t *testing.T) { h := NewCaptainAssistantHandler(nil) assert.NotNil(t, h) } func TestNewCompanyHandler_Cov8(t *testing.T) { h := NewCompanyHandler(nil) assert.NotNil(t, h) } func TestNewConversationHandler_Cov8(t *testing.T) { h := NewConversationHandler(nil, nil) assert.NotNil(t, h) } func TestNewLabelHandler_Cov8(t *testing.T) { h := NewLabelHandler(nil, nil) assert.NotNil(t, h) } func TestNewMacroHandler_Cov8(t *testing.T) { h := NewMacroHandler(nil) assert.NotNil(t, h) } func TestNewMessageHandler_Cov8(t *testing.T) { h := NewMessageHandler(nil) assert.NotNil(t, h) } func TestNewNoteHandler_Cov8(t *testing.T) { h := NewNoteHandler(nil) assert.NotNil(t, h) } func TestNewTeamHandler_Cov8(t *testing.T) { h := NewTeamHandler(nil) assert.NotNil(t, h) } func TestNewUploadHandler_Cov8(t *testing.T) { h := NewUploadHandler(nil) assert.NotNil(t, h) } func TestNewAuditHandler_Cov8(t *testing.T) { h := NewAuditHandler(nil) assert.NotNil(t, h) } func TestNewBannerHandler_Cov8(t *testing.T) { h := NewBannerHandler(nil) assert.NotNil(t, h) } func TestNewFolderHandler_Cov8(t *testing.T) { h := NewFolderHandler(nil) assert.NotNil(t, h) } func TestNewSlaPolicyHandler_Cov8(t *testing.T) { h := NewSlaPolicyHandler(nil) assert.NotNil(t, h) } func TestNewCsatMetricsHandler_Cov8(t *testing.T) { h := NewCsatMetricsHandler(nil) assert.NotNil(t, h) } func TestNewDashboardAppHandler_Cov8(t *testing.T) { h := NewDashboardAppHandler(nil) assert.NotNil(t, h) } func TestNewDeliveryStatusHandler_Cov8(t *testing.T) { h := NewDeliveryStatusHandler(nil) assert.NotNil(t, h) } func TestNewDraftMessageHandler_Cov8(t *testing.T) { h := NewDraftMessageHandler(nil) assert.NotNil(t, h) } func TestNewEnterpriseAccountHandler_Cov8(t *testing.T) { h := NewEnterpriseAccountHandler(nil) assert.NotNil(t, h) } func TestNewInstallationConfigHandler_Cov8(t *testing.T) { h := NewInstallationConfigHandler(nil) assert.NotNil(t, h) } func TestNewIntegrationHookHandler_Cov8(t *testing.T) { h := NewIntegrationHookHandler(nil) assert.NotNil(t, h) } func TestNewLiveReportHandler_Cov8(t *testing.T) { h := NewLiveReportHandler(nil) assert.NotNil(t, h) } func TestNewNotionIntegrationHandler_Cov8(t *testing.T) { h := NewNotionIntegrationHandler(nil) assert.NotNil(t, h) } func TestNewRAGHandler_Cov8(t *testing.T) { h := NewRAGHandler(nil) assert.NotNil(t, h) } func TestNewReportingEventHandler_Cov8(t *testing.T) { h := NewReportingEventHandler(nil) assert.NotNil(t, h) } func TestNewSlackIntegrationHandler_Cov8(t *testing.T) { h := NewSlackIntegrationHandler(nil) assert.NotNil(t, h) } func TestNewSummaryReportHandler_Cov8(t *testing.T) { h := NewSummaryReportHandler(nil) assert.NotNil(t, h) } func TestNewWidgetTestHandler_Cov8(t *testing.T) { h := NewWidgetTestHandler(nil) assert.NotNil(t, h) } func TestNewWorkingHourHandler_Cov8(t *testing.T) { h := NewWorkingHourHandler(nil) assert.NotNil(t, h) } func TestNewYearInReviewHandler_Cov8(t *testing.T) { h := NewYearInReviewHandler(nil) assert.NotNil(t, h) } // ================================================================= // Additional nil-service handler method tests // ================================================================= func TestWhatsAppCallHandler_Index_NoSvc_Cov8(t *testing.T) { h := NewWhatsAppCallHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Index(c) }) } func TestWhatsAppCallHandler_Show_NoSvc_Cov8(t *testing.T) { h := NewWhatsAppCallHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Show(c) }) } func TestShopifyIntegrationHandler_Delete_NoSvc_Cov8(t *testing.T) { h := NewShopifyIntegrationHandler(nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.Delete(c) }) } func TestShopifyIntegrationHandler_Auth_NoSvc_Cov8(t *testing.T) { h := NewShopifyIntegrationHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Auth(c) }) } func TestShopifyIntegrationHandler_GetOrders_NoSvc_Cov8(t *testing.T) { h := NewShopifyIntegrationHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.GetOrders(c) }) } func TestLinearIntegrationHandler_Delete_NoSvc_Cov8(t *testing.T) { h := NewLinearIntegrationHandler(nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.Delete(c) }) } func TestLinearIntegrationHandler_GetTeams_NoSvc_Cov8(t *testing.T) { h := NewLinearIntegrationHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.GetTeams(c) }) } func TestLinearIntegrationHandler_GetTeamEntities_NoSvc_Cov8(t *testing.T) { h := NewLinearIntegrationHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.GetTeamEntities(c) }) } func TestLinearIntegrationHandler_CreateIssue_NoSvc_Cov8(t *testing.T) { h := NewLinearIntegrationHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.CreateIssue(c) }) } func TestLinearIntegrationHandler_LinkIssue_NoSvc_Cov8(t *testing.T) { h := NewLinearIntegrationHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.LinkIssue(c) }) } func TestLinearIntegrationHandler_UnlinkIssue_NoSvc_Cov8(t *testing.T) { h := NewLinearIntegrationHandler(nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.UnlinkIssue(c) }) } func TestLinearIntegrationHandler_SearchIssue_NoSvc_Cov8(t *testing.T) { h := NewLinearIntegrationHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.SearchIssue(c) }) } func TestLinearIntegrationHandler_GetLinkedIssues_NoSvc_Cov8(t *testing.T) { h := NewLinearIntegrationHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.GetLinkedIssues(c) }) } func TestWebhookSubscriptionHandler_List_NoSvc_Cov8(t *testing.T) { h := NewWebhookSubscriptionHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.List(c) }) } func TestWebhookSubscriptionHandler_Get_NoSvc_Cov8(t *testing.T) { h := NewWebhookSubscriptionHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Get(c) }) } func TestWebhookSubscriptionHandler_Create_NoSvc_Cov8(t *testing.T) { h := NewWebhookSubscriptionHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Create(c) }) } func TestWebhookSubscriptionHandler_Update_NoSvc_Cov8(t *testing.T) { h := NewWebhookSubscriptionHandler(nil) c, _ := newCtx_Cov8("PUT", "/") safeCall_Cov8(t, func() { h.Update(c) }) } func TestWebhookSubscriptionHandler_Delete_NoSvc_Cov8(t *testing.T) { h := NewWebhookSubscriptionHandler(nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.Delete(c) }) } func TestWebhookSubscriptionHandler_ListDeliveries_NoSvc_Cov8(t *testing.T) { h := NewWebhookSubscriptionHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.ListDeliveries(c) }) } func TestPlatformAppHandler_List_NoSvc_Cov8(t *testing.T) { h := NewPlatformAppHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.List(c) }) } func TestPlatformAppHandler_Get_NoSvc_Cov8(t *testing.T) { h := NewPlatformAppHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Get(c) }) } func TestPlatformAppHandler_Create_NoSvc_Cov8(t *testing.T) { h := NewPlatformAppHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Create(c) }) } func TestPlatformAppHandler_Update_NoSvc_Cov8(t *testing.T) { h := NewPlatformAppHandler(nil) c, _ := newCtx_Cov8("PUT", "/") safeCall_Cov8(t, func() { h.Update(c) }) } func TestPlatformAppHandler_Delete_NoSvc_Cov8(t *testing.T) { h := NewPlatformAppHandler(nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.Delete(c) }) } func TestPlatformAppHandler_RegenerateAccessToken_NoSvc_Cov8(t *testing.T) { h := NewPlatformAppHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.RegenerateAccessToken(c) }) } func TestPlatformAppHandler_ListAccessTokens_NoSvc_Cov8(t *testing.T) { h := NewPlatformAppHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.ListAccessTokens(c) }) } func TestPlatformAppHandler_AddPermissible_NoSvc_Cov8(t *testing.T) { h := NewPlatformAppHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.AddPermissible(c) }) } func TestPlatformAppHandler_RemovePermissible_NoSvc_Cov8(t *testing.T) { h := NewPlatformAppHandler(nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.RemovePermissible(c) }) } func TestPlatformAppHandler_ListPermissibles_NoSvc_Cov8(t *testing.T) { h := NewPlatformAppHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.ListPermissibles(c) }) } func TestPlatformAppHandler_Search_NoSvc_Cov8(t *testing.T) { h := NewPlatformAppHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Search(c) }) } func TestPlatformUserHandler_Show_NoSvc_Cov8(t *testing.T) { h := NewPlatformUserHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Show(c) }) } func TestPlatformUserHandler_Create_NoSvc_Cov8(t *testing.T) { h := NewPlatformUserHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Create(c) }) } func TestPlatformUserHandler_Login_NoSvc_Cov8(t *testing.T) { h := NewPlatformUserHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Login(c) }) } func TestPlatformUserHandler_Token_NoSvc_Cov8(t *testing.T) { h := NewPlatformUserHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Token(c) }) } func TestPlatformUserHandler_Update_NoSvc_Cov8(t *testing.T) { h := NewPlatformUserHandler(nil) c, _ := newCtx_Cov8("PUT", "/") safeCall_Cov8(t, func() { h.Update(c) }) } func TestPlatformUserHandler_Destroy_NoSvc_Cov8(t *testing.T) { h := NewPlatformUserHandler(nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.Destroy(c) }) } func TestPlatformUserHandler_List_NoSvc_Cov8(t *testing.T) { h := NewPlatformUserHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.List(c) }) } func TestInboxCsatTemplateHandler_Show_NoSvc_Cov8(t *testing.T) { h := NewInboxCsatTemplateHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Show(c) }) } func TestInboxCsatTemplateHandler_Create_NoSvc_Cov8(t *testing.T) { h := NewInboxCsatTemplateHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Create(c) }) } func TestInboxCsatTemplateHandler_Analyze_NoSvc_Cov8(t *testing.T) { h := NewInboxCsatTemplateHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Analyze(c) }) } func TestNotificationHandler_List_NoSvc_Cov8(t *testing.T) { h := NewNotificationHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.List(c) }) } func TestNotificationHandler_Get_NoSvc_Cov8(t *testing.T) { h := NewNotificationHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Get(c) }) } func TestNotificationHandler_Update_NoSvc_Cov8(t *testing.T) { h := NewNotificationHandler(nil) c, _ := newCtx_Cov8("PUT", "/") safeCall_Cov8(t, func() { h.Update(c) }) } func TestNotificationHandler_MarkAllRead_NoSvc_Cov8(t *testing.T) { h := NewNotificationHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.MarkAllRead(c) }) } func TestNotificationHandler_UnreadCount_NoSvc_Cov8(t *testing.T) { h := NewNotificationHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.UnreadCount(c) }) } func TestNotificationHandler_Snooze_NoSvc_Cov8(t *testing.T) { h := NewNotificationHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Snooze(c) }) } func TestNotificationHandler_Unread_NoSvc_Cov8(t *testing.T) { h := NewNotificationHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Unread(c) }) } func TestNotificationHandler_Destroy_NoSvc_Cov8(t *testing.T) { h := NewNotificationHandler(nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.Destroy(c) }) } func TestNotificationHandler_DestroyAll_NoSvc_Cov8(t *testing.T) { h := NewNotificationHandler(nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.DestroyAll(c) }) } func TestPortalHandler_PublicRedirectDefaultLocale_NoSvc_Cov8(t *testing.T) { h := NewPortalHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.PublicRedirectDefaultLocale(c) }) } func TestPortalHandler_PublicGet_NoSvc_Cov8(t *testing.T) { h := NewPortalHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.PublicGet(c) }) } func TestPortalHandler_PublicSitemap_NoSvc_Cov8(t *testing.T) { h := NewPortalHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.PublicSitemap(c) }) } func TestPortalHandler_Create_NoSvc_Cov8(t *testing.T) { h := NewPortalHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Create(c) }) } func TestPortalHandler_Get_NoSvc_Cov8(t *testing.T) { h := NewPortalHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Get(c) }) } func TestPortalHandler_Update_NoSvc_Cov8(t *testing.T) { h := NewPortalHandler(nil) c, _ := newCtx_Cov8("PUT", "/") safeCall_Cov8(t, func() { h.Update(c) }) } func TestPortalHandler_Delete_NoSvc_Cov8(t *testing.T) { h := NewPortalHandler(nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.Delete(c) }) } func TestPortalHandler_List_NoSvc_Cov8(t *testing.T) { h := NewPortalHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.List(c) }) } func TestPortalHandler_Archive_NoSvc_Cov8(t *testing.T) { h := NewPortalHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Archive(c) }) } func TestPortalHandler_RemoveLogo_NoSvc_Cov8(t *testing.T) { h := NewPortalHandler(nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.RemoveLogo(c) }) } func TestPortalHandler_SendInstructions_NoSvc_Cov8(t *testing.T) { h := NewPortalHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.SendInstructions(c) }) } func TestPortalHandler_SSLStatus_NoSvc_Cov8(t *testing.T) { h := NewPortalHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.SSLStatus(c) }) } func TestCategoryHandler_PublicList_NoSvc_Cov8(t *testing.T) { h := NewCategoryHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.PublicList(c) }) } func TestCategoryHandler_PublicGet_NoSvc_Cov8(t *testing.T) { h := NewCategoryHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.PublicGet(c) }) } func TestCategoryHandler_Create_NoSvc_Cov8(t *testing.T) { h := NewCategoryHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Create(c) }) } func TestCategoryHandler_Get_NoSvc_Cov8(t *testing.T) { h := NewCategoryHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Get(c) }) } func TestCategoryHandler_Update_NoSvc_Cov8(t *testing.T) { h := NewCategoryHandler(nil) c, _ := newCtx_Cov8("PUT", "/") safeCall_Cov8(t, func() { h.Update(c) }) } func TestCategoryHandler_Delete_NoSvc_Cov8(t *testing.T) { h := NewCategoryHandler(nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.Delete(c) }) } func TestCategoryHandler_List_NoSvc_Cov8(t *testing.T) { h := NewCategoryHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.List(c) }) } func TestCategoryHandler_Reorder_NoSvc_Cov8(t *testing.T) { h := NewCategoryHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Reorder(c) }) } // ================================================================= // InstagramChannelHandler nil-service tests // ================================================================= func TestInstagramChannelHandler_Authorization_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Authorization(c) }) } func TestInstagramChannelHandler_ChatwootAuthorization_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.ChatwootAuthorization(c) }) } func TestInstagramChannelHandler_OAuthCallback_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.OAuthCallback(c) }) } func TestInstagramChannelHandler_OAuthCallbackGET_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.OAuthCallbackGET(c) }) } func TestInstagramChannelHandler_RegisterWebhook_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.RegisterWebhook(c) }) } func TestInstagramChannelHandler_ListWebhooks_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.ListWebhooks(c) }) } func TestInstagramChannelHandler_CreateInstagramChannel_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.CreateInstagramChannel(c) }) } func TestInstagramChannelHandler_DeleteInstagramChannel_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.DeleteInstagramChannel(c) }) } func TestInstagramChannelHandler_Reauthorize_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Reauthorize(c) }) } func TestInstagramChannelHandler_GetInstagramChannel_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.GetInstagramChannel(c) }) } func TestInstagramChannelHandler_ListInstagramChannels_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.ListInstagramChannels(c) }) } func TestInstagramChannelHandler_GetComments_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.GetComments(c) }) } func TestInstagramChannelHandler_GetCommentReplies_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.GetCommentReplies(c) }) } func TestInstagramChannelHandler_ReplyToComment_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.ReplyToComment(c) }) } func TestInstagramChannelHandler_HideComment_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.HideComment(c) }) } func TestInstagramChannelHandler_DeleteComment_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.DeleteComment(c) }) } func TestInstagramChannelHandler_UpdateInstagramChannel_NoSvc_Cov8(t *testing.T) { h := NewInstagramChannelHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("PUT", "/") safeCall_Cov8(t, func() { h.UpdateInstagramChannel(c) }) } // ================================================================= // BulkActionHandler nil-service tests // ================================================================= func TestBulkActionHandler_Create_NoSvc_Cov8(t *testing.T) { h := NewBulkActionHandler(nil, nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Create(c) }) } // ================================================================= // AuthHandler nil-service tests // ================================================================= func TestAuthHandler_Login_NoSvc_Cov8(t *testing.T) { h := NewAuthHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Login(c) }) } func TestAuthHandler_Refresh_NoSvc_Cov8(t *testing.T) { h := NewAuthHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Refresh(c) }) } func TestAuthHandler_Logout_NoSvc_Cov8(t *testing.T) { h := NewAuthHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Logout(c) }) } func TestAuthHandler_SwitchAccount_NoSvc_Cov8(t *testing.T) { h := NewAuthHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.SwitchAccount(c) }) } func TestAuthHandler_ResetPassword_NoSvc_Cov8(t *testing.T) { h := NewAuthHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.ResetPassword(c) }) } func TestAuthHandler_ConfirmResetPassword_NoSvc_Cov8(t *testing.T) { h := NewAuthHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.ConfirmResetPassword(c) }) } func TestAuthHandler_ConfirmEmail_NoSvc_Cov8(t *testing.T) { h := NewAuthHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.ConfirmEmail(c) }) } func TestAuthHandler_ChatwootConfirmEmail_NoSvc_Cov8(t *testing.T) { h := NewAuthHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.ChatwootConfirmEmail(c) }) } func TestAuthHandler_ChatwootSignIn_NoSvc_Cov8(t *testing.T) { h := NewAuthHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.ChatwootSignIn(c) }) } func TestAuthHandler_ChatwootValidateToken_NoSvc_Cov8(t *testing.T) { h := NewAuthHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.ChatwootValidateToken(c) }) } func TestAuthHandler_ChatwootSignOut_NoSvc_Cov8(t *testing.T) { h := NewAuthHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.ChatwootSignOut(c) }) } // ================================================================= // ContactHandler nil-service tests // ================================================================= func TestContactHandler_List_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.List(c) }) } func TestContactHandler_Search_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Search(c) }) } func TestContactHandler_Get_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Get(c) }) } func TestContactHandler_Create_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Create(c) }) } func TestContactHandler_Update_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("PUT", "/") safeCall_Cov8(t, func() { h.Update(c) }) } func TestContactHandler_Delete_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.Delete(c) }) } func TestContactHandler_DeleteAvatar_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.DeleteAvatar(c) }) } func TestContactHandler_ListLabels_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.ListLabels(c) }) } func TestContactHandler_UpdateLabels_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.UpdateLabels(c) }) } func TestContactHandler_ListContactInboxes_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.ListContactInboxes(c) }) } func TestContactHandler_ListConversations_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.ListConversations(c) }) } func TestContactHandler_ListNotes_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.ListNotes(c) }) } func TestContactHandler_CreateNote_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.CreateNote(c) }) } func TestContactHandler_ShowNote_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.ShowNote(c) }) } func TestContactHandler_UpdateNote_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("PUT", "/") safeCall_Cov8(t, func() { h.UpdateNote(c) }) } func TestContactHandler_DestroyNote_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.DestroyNote(c) }) } func TestContactHandler_InitiateCall_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.InitiateCall(c) }) } func TestContactHandler_CreateContactInbox_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.CreateContactInbox(c) }) } func TestContactHandler_DeleteContactInbox_NoSvc_Cov8(t *testing.T) { h := NewContactHandler(nil, nil, nil, nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.DeleteContactInbox(c) }) } // ================================================================= // InboxHandler nil-service tests // ================================================================= func TestInboxHandler_List_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.List(c) }) } func TestInboxHandler_Get_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Get(c) }) } func TestInboxHandler_Create_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.Create(c) }) } func TestInboxHandler_Update_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("PUT", "/") safeCall_Cov8(t, func() { h.Update(c) }) } func TestInboxHandler_Delete_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.Delete(c) }) } func TestInboxHandler_WhatsAppAuthorization_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.WhatsAppAuthorization(c) }) } func TestInboxHandler_SetAgentBot_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.SetAgentBot(c) }) } func TestInboxHandler_GetAgentBot_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.GetAgentBot(c) }) } func TestInboxHandler_Health_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.Health(c) }) } func TestInboxHandler_SyncTemplates_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.SyncTemplates(c) }) } func TestInboxHandler_RegisterWebhook_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.RegisterWebhook(c) }) } func TestInboxHandler_DeleteAvatar_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("DELETE", "/") safeCall_Cov8(t, func() { h.DeleteAvatar(c) }) } func TestInboxHandler_ListCampaigns_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.ListCampaigns(c) }) } func TestInboxHandler_ResetSecret_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.ResetSecret(c) }) } func TestInboxHandler_EnableWhatsAppCalling_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.EnableWhatsAppCalling(c) }) } func TestInboxHandler_DisableWhatsAppCalling_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.DisableWhatsAppCalling(c) }) } func TestInboxHandler_SetInboundCalls_NoSvc_Cov8(t *testing.T) { h := NewInboxHandler(nil) c, _ := newCtx_Cov8("POST", "/") safeCall_Cov8(t, func() { h.SetInboundCalls(c) }) } // ================================================================= // SSEEventHandler nil-service tests // ================================================================= func TestSSEEventHandler_StreamEvents_NoSvc_Cov8(t *testing.T) { h := NewSSEEventHandler(nil) c, _ := newCtx_Cov8("GET", "/") safeCall_Cov8(t, func() { h.StreamEvents(c) }) } // ================================================================= // AutomationRuleHandler nil-service tests // ================================================================= func TestNewAutomationRuleHandler_Nil_Cov8(t *testing.T) { h := NewAutomationRuleHandler(nil) assert.NotNil(t, h) } // ================================================================= // helper: assertError // ================================================================= type cov8AssertError struct{ msg string } func (e *cov8AssertError) Error() string { return e.msg } func assertError_Cov8(msg string) error { return &cov8AssertError{msg: msg} } // Keep imports used var ( _ = automation.AutomationRuleService{} _ = canned.CannedResponseService{} _ = repository.WorkingHourUpdateParam{} _ = search.SearchResult{} _ = service.AccountService{} _ = gorm.ErrRecordNotFound )