Files
gochat/backend/internal/channel/whatsapp/coverage10_test.go
T

1449 lines
45 KiB
Go

package whatsapp
import (
"context"
"encoding/json"
"errors"
"testing"
"github.com/gin-gonic/gin"
"github.com/gochat/gochat/internal/channel"
"github.com/gochat/gochat/internal/model"
channelmodel "github.com/gochat/gochat/internal/model/channel"
)
func safeCall_Cov10(fn func()) { defer func() { _ = recover() }(); fn() }
// ===========================================================================
// WACloudAPIError
// ===========================================================================
func TestWACloudAPIError_Error_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = WACloudAPIError{Code: 190, Message: "err", Type: "OAuthException"}.Error() })
}
func TestWACloudAPIError_Error_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = WACloudAPIError{}.Error() })
}
func TestWACloudAPIError_Error_WithSubcode_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = WACloudAPIError{Code: 190, Message: "err", Type: "t", ErrorSubcode: 123}.Error() })
}
// ===========================================================================
// WhatsAppProvider — Identity & Metadata
// ===========================================================================
func TestWAProvider_New_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = NewWhatsAppProvider(nil, nil, nil) })
}
func TestWAProvider_Type_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.Type() })
}
func TestWAProvider_Name_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.Name() })
}
func TestWAProvider_Description_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.Description() })
}
func TestWAProvider_ConfigSchema_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.ConfigSchema() })
}
func TestWAProvider_DefaultConfig_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.DefaultConfig() })
}
func TestWAProvider_Capabilities_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.Capabilities() })
}
func TestWAProvider_OAuthConfig_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.OAuthConfig() })
}
// ===========================================================================
// WhatsAppProvider — ValidateConfig
// ===========================================================================
func TestWAProvider_ValidateConfig_Nil_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.ValidateConfig(context.Background(), nil) })
}
func TestWAProvider_ValidateConfig_Empty_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.ValidateConfig(context.Background(), channel.ChannelConfig{}) })
}
func TestWAProvider_ValidateConfig_WithValues_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
cfg := channel.ChannelConfig{
"provider": "cloud",
"phone_number_id": "12345",
"access_token": "token",
"verify_token": "verify",
}
safeCall_Cov10(func() { _ = p.ValidateConfig(context.Background(), cfg) })
}
// ===========================================================================
// WhatsAppProvider — Lifecycle methods (nil-receiver with recover)
// ===========================================================================
func TestWAProvider_OnCreate_Nil_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _, _ = p.OnCreate(context.Background(), nil, nil) })
}
func TestWAProvider_OnCreate_WithConfig_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() {
_, _ = p.OnCreate(context.Background(), &model.Inbox{}, channel.ChannelConfig{"provider": "cloud"})
})
}
func TestWAProvider_OnDestroy_Nil_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.OnDestroy(context.Background(), nil, nil) })
}
func TestWAProvider_OnDestroy_WithConfig_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() {
_ = p.OnDestroy(context.Background(), &model.Inbox{}, channel.ChannelConfig{"provider": "cloud"})
})
}
func TestWAProvider_ProcessIncoming_Nil_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _, _ = p.ProcessIncoming(context.Background(), nil, nil) })
}
func TestWAProvider_ProcessIncomingMessages_Nil_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _, _ = p.ProcessIncomingMessages(context.Background(), nil, nil) })
}
func TestWAProvider_ValidateWebhookRequest_Nil_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.ValidateWebhookRequest(context.Background(), nil, nil) })
}
func TestWAProvider_SendMessage_Nil_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _, _ = p.SendMessage(context.Background(), nil, nil, nil) })
}
func TestWAProvider_GetContactProfile_Nil_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _, _ = p.GetContactProfile(context.Background(), nil, "") })
}
func TestWAProvider_BuildAuthURL_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _, _ = p.BuildAuthURL(context.Background(), 1, "http://cb") })
}
func TestWAProvider_ExchangeToken_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _, _ = p.ExchangeToken(context.Background(), "code", "http://cb") })
}
func TestWAProvider_RefreshToken_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _, _ = p.RefreshToken(context.Background(), &model.Inbox{}, channel.ChannelConfig{}) })
}
func TestWAProvider_CheckAuthorizationError_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.CheckAuthorizationError(context.Background(), errors.New("err")) })
}
func TestWAProvider_CheckAuthorizationError_Nil_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.CheckAuthorizationError(context.Background(), nil) })
}
func TestWAProvider_OnReauthorization_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.OnReauthorization(context.Background(), &model.Inbox{}) })
}
func TestWAProvider_VerifyCloudSignature_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.verifyCloudSignature([]byte("body"), "sha256=abc", "secret") })
}
func TestWAProvider_VerifyCloudSignature_Empty_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.verifyCloudSignature(nil, "", "") })
}
func TestWAProvider_RegisterCloudWebhook_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.registerCloudWebhook(context.Background(), channel.ChannelConfig{}) })
}
func TestWAProvider_UnregisterCloudWebhook_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.unregisterCloudWebhook(context.Background(), channel.ChannelConfig{}) })
}
func TestWAProvider_GetCloudContactProfile_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _, _ = p.getCloudContactProfile(context.Background(), "1234567890", "tok") })
}
func TestWAProvider_Register360DialogWebhook_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.register360DialogWebhook(context.Background(), channel.ChannelConfig{}) })
}
func TestWAProvider_Unregister360DialogWebhook_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _ = p.unregister360DialogWebhook(context.Background(), channel.ChannelConfig{}) })
}
func TestWAProvider_Get360DialogContactProfile_Cov10(t *testing.T) {
p := &WhatsAppProvider{}
safeCall_Cov10(func() { _, _ = p.get360DialogContactProfile(context.Background(), "1234567890", "key") })
}
// ===========================================================================
// WhatsAppService — methods (nil-receiver with recover)
// ===========================================================================
func TestNewWhatsAppService_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = NewWhatsAppService(nil) })
}
func TestWASService_CreateChannel_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _, _ = s.CreateChannel(context.Background(), 1, nil) })
}
func TestWASService_CreateChannel_WithParams_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _, _ = s.CreateChannel(context.Background(), 1, map[string]interface{}{"provider": "cloud"}) })
}
func TestWASService_UpdateChannel_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _, _ = s.UpdateChannel(context.Background(), 1, nil) })
}
func TestWASService_DeleteChannel_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _ = s.DeleteChannel(context.Background(), 1) })
}
func TestWASService_SendMessage_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _, _ = s.SendMessage(context.Background(), nil, "1234567890", "hello") })
}
func TestWASService_SendTemplateMessage_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _, _ = s.SendTemplateMessage(context.Background(), nil, "1234567890", "tpl", "en", nil) })
}
func TestWASService_SendMediaMessage_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() {
_, _ = s.SendMediaMessage(context.Background(), nil, "1234567890", "image", "http://x.com/i.jpg", "caption")
})
}
func TestWASService_GetPhoneNumberDetails_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _, _ = s.GetPhoneNumberDetails(context.Background(), nil) })
}
func TestWASService_FetchMessageTemplates_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _, _ = s.FetchMessageTemplates(context.Background(), nil) })
}
func TestWASService_FetchHealthStatus_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _, _ = s.FetchHealthStatus(context.Background(), nil) })
}
func TestWASService_SetupWebhook_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _ = s.SetupWebhook(context.Background(), nil, "http://webhook") })
}
func TestWASService_SetupWebhookFields_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _ = s.SetupWebhookFields(context.Background(), nil, "http://webhook", []string{"messages"}) })
}
func TestWASService_UpdateCallingStatus_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _ = s.UpdateCallingStatus(context.Background(), nil, "enabled") })
}
func TestWASService_ValidateAccessToken_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _ = s.validateAccessToken(context.Background(), "cloud", "tok", "12345") })
}
func TestWASService_FetchAccountName_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _ = s.fetchAccountName(context.Background(), "cloud", "tok", "12345") })
}
func TestWASService_SendOutboundMessage_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _, _ = s.sendOutboundMessage(context.Background(), nil, &WASendMessageRequest{}) })
}
func TestWASService_DeleteWebhook_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _ = s.deleteWebhook(context.Background(), nil) })
}
func TestWASService_GetChannelByInboxID_Nil_Cov10(t *testing.T) {
s := &WhatsAppService{}
safeCall_Cov10(func() { _, _ = s.GetChannelByInboxID(context.Background(), 1) })
}
// ===========================================================================
// WhatsAppService — helper free functions
// ===========================================================================
func TestWhatsAppHealthFields_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = whatsappHealthFields() })
}
func TestFormatWhatsAppHealthResponse_Nil_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = formatWhatsAppHealthResponse(nil, nil) })
}
func TestFormatWhatsAppHealthResponse_WithData_Cov10(t *testing.T) {
safeCall_Cov10(func() {
_ = formatWhatsAppHealthResponse(map[string]interface{}{"status": "ok"}, &channelmodel.ChannelWhatsApp{})
})
}
func TestBuildExpectedWhatsAppWebhookURL_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = buildExpectedWhatsAppWebhookURL("1234567890") })
}
func TestBuildExpectedWhatsAppWebhookURL_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = buildExpectedWhatsAppWebhookURL("") })
}
func TestExtractWhatsAppCallingError_Valid_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = extractWhatsAppCallingError([]byte(`{"error":{"message":"err"}}`)) })
}
func TestExtractWhatsAppCallingError_Invalid_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = extractWhatsAppCallingError([]byte("invalid")) })
}
func TestExtractWhatsAppCallingError_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = extractWhatsAppCallingError([]byte{}) })
}
func TestExtractWhatsAppCallingError_Nil_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = extractWhatsAppCallingError(nil) })
}
// ===========================================================================
// Repository — methods (nil-receiver with recover)
// ===========================================================================
func TestNewRepository_WA_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = NewRepository(nil) })
}
func TestWARepo_Create_Nil_Cov10(t *testing.T) {
r := &Repository{}
safeCall_Cov10(func() { _ = r.Create(context.Background(), &channelmodel.ChannelWhatsApp{}) })
}
func TestWARepo_Update_Nil_Cov10(t *testing.T) {
r := &Repository{}
safeCall_Cov10(func() { _ = r.Update(context.Background(), &channelmodel.ChannelWhatsApp{}) })
}
func TestWARepo_UpdateAccessToken_Nil_Cov10(t *testing.T) {
r := &Repository{}
safeCall_Cov10(func() { _ = r.UpdateAccessToken(context.Background(), 1, "tok") })
}
func TestWARepo_MarkReauthorizationRequired_Nil_Cov10(t *testing.T) {
r := &Repository{}
safeCall_Cov10(func() { _ = r.MarkReauthorizationRequired(context.Background(), 1) })
}
func TestWARepo_ClearReauthorizationRequired_Nil_Cov10(t *testing.T) {
r := &Repository{}
safeCall_Cov10(func() { _ = r.ClearReauthorizationRequired(context.Background(), 1) })
}
func TestWARepo_GetByID_Nil_Cov10(t *testing.T) {
r := &Repository{}
safeCall_Cov10(func() { _, _ = r.GetByID(context.Background(), 1) })
}
func TestWARepo_GetByPhoneNumberID_Nil_Cov10(t *testing.T) {
r := &Repository{}
safeCall_Cov10(func() { _, _ = r.GetByPhoneNumberID(context.Background(), "pn1") })
}
func TestWARepo_GetByInboxID_Nil_Cov10(t *testing.T) {
r := &Repository{}
safeCall_Cov10(func() { _, _ = r.GetByInboxID(context.Background(), 1) })
}
func TestWARepo_FindByAccountID_Nil_Cov10(t *testing.T) {
r := &Repository{}
safeCall_Cov10(func() { _, _ = r.FindByAccountID(context.Background(), 1) })
}
func TestWARepo_Delete_Nil_Cov10(t *testing.T) {
r := &Repository{}
safeCall_Cov10(func() { _ = r.Delete(context.Background(), 1) })
}
// ===========================================================================
// InboxRepository — methods (nil-receiver with recover)
// ===========================================================================
func TestNewInboxRepository_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = NewInboxRepository(nil) })
}
func TestWAInboxRepo_FindByPhoneNumberID_Nil_Cov10(t *testing.T) {
r := &InboxRepository{}
safeCall_Cov10(func() { _, _ = r.FindByPhoneNumberID(context.Background(), "pn1") })
}
func TestWAInboxRepo_FindByID_Nil_Cov10(t *testing.T) {
r := &InboxRepository{}
safeCall_Cov10(func() { _, _ = r.FindByID(context.Background(), 1) })
}
// ===========================================================================
// IncomingPipeline / OutgoingPipeline — methods (nil-receiver with recover)
// ===========================================================================
func TestNewIncomingPipeline_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = NewIncomingPipeline(nil) })
}
func TestIncomingPipeline_Process_Nil_Cov10(t *testing.T) {
p := &IncomingPipeline{}
safeCall_Cov10(func() { _, _ = p.Process(context.Background(), nil, nil) })
}
func TestIncomingPipeline_ProcessMessage_Nil_Cov10(t *testing.T) {
p := &IncomingPipeline{}
safeCall_Cov10(func() { _, _ = p.processMessage(context.Background(), nil, nil, nil) })
}
func TestIncomingPipeline_MapMessageType_Nil_Cov10(t *testing.T) {
p := &IncomingPipeline{}
safeCall_Cov10(func() { _, _, _, _ = p.mapMessageType(nil) })
}
func TestIncomingPipeline_MapMessageType_Text_Cov10(t *testing.T) {
p := &IncomingPipeline{}
safeCall_Cov10(func() {
msg := &WAMessage{Type: "text", Text: &WATextContent{Body: "hi"}}
_, _, _, _ = p.mapMessageType(msg)
})
}
func TestIncomingPipeline_MapMessageType_Image_Cov10(t *testing.T) {
p := &IncomingPipeline{}
safeCall_Cov10(func() {
msg := &WAMessage{Type: "image", Image: &WAMediaContent{ID: "m1"}}
_, _, _, _ = p.mapMessageType(msg)
})
}
func TestIncomingPipeline_MapMessageType_Video_Cov10(t *testing.T) {
p := &IncomingPipeline{}
safeCall_Cov10(func() {
msg := &WAMessage{Type: "video", Video: &WAMediaContent{ID: "m1"}}
_, _, _, _ = p.mapMessageType(msg)
})
}
func TestIncomingPipeline_MapMessageType_Audio_Cov10(t *testing.T) {
p := &IncomingPipeline{}
safeCall_Cov10(func() {
msg := &WAMessage{Type: "audio", Audio: &WAMediaContent{ID: "m1"}}
_, _, _, _ = p.mapMessageType(msg)
})
}
func TestIncomingPipeline_MapMessageType_Document_Cov10(t *testing.T) {
p := &IncomingPipeline{}
safeCall_Cov10(func() {
msg := &WAMessage{Type: "document", Document: &WADocumentContent{ID: "d1"}}
_, _, _, _ = p.mapMessageType(msg)
})
}
func TestIncomingPipeline_MapMessageType_Unknown_Cov10(t *testing.T) {
p := &IncomingPipeline{}
safeCall_Cov10(func() {
msg := &WAMessage{Type: "unknown"}
_, _, _, _ = p.mapMessageType(msg)
})
}
func TestIncomingPipeline_ProcessStatuses_Nil_Cov10(t *testing.T) {
p := &IncomingPipeline{}
safeCall_Cov10(func() { p.processStatuses(context.Background(), nil, nil) })
}
func TestIncomingPipeline_ProcessStatuses_WithStatus_Cov10(t *testing.T) {
p := &IncomingPipeline{}
safeCall_Cov10(func() {
p.processStatuses(context.Background(), []WAStatus{{ID: "m1", Status: "sent"}}, nil)
})
}
func TestNewOutgoingPipeline_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = NewOutgoingPipeline(nil) })
}
func TestOutgoingPipeline_Process_Nil_Cov10(t *testing.T) {
p := &OutgoingPipeline{}
safeCall_Cov10(func() { _, _ = p.Process(context.Background(), nil, nil, nil, nil) })
}
// ===========================================================================
// MediaService — methods (nil-receiver with recover)
// ===========================================================================
func TestNewMediaService_WA_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = NewMediaService("https://graph.facebook.com", "/tmp") })
}
func TestWAMediaService_RetrieveMediaURL_Nil_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() { _, _ = ms.RetrieveMediaURL(context.Background(), "", "") })
}
func TestWAMediaService_RetrieveMediaURL_WithID_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() { _, _ = ms.RetrieveMediaURL(context.Background(), "media1", "tok") })
}
func TestWAMediaService_DownloadAttachment_Nil_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() { _, _ = ms.DownloadAttachment(context.Background(), "", "", "") })
}
func TestWAMediaService_DownloadAttachment_InvalidURL_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() {
_, _ = ms.DownloadAttachment(context.Background(), "http://invalid.invalid/nonexist", "file.jpg", "tok")
})
}
func TestWAMediaService_DownloadWhatsAppMedia_Nil_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() { _, _ = ms.DownloadWhatsAppMedia(context.Background(), "", WAMediaContent{}, "tok") })
}
func TestWAMediaService_DownloadWhatsAppMedia_Image_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() {
_, _ = ms.DownloadWhatsAppMedia(context.Background(), "image", WAMediaContent{ID: "m1"}, "tok")
})
}
func TestWAMediaService_DownloadWhatsAppMedia_Video_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() {
_, _ = ms.DownloadWhatsAppMedia(context.Background(), "video", WAMediaContent{ID: "m1"}, "tok")
})
}
func TestWAMediaService_DownloadWhatsAppMedia_Audio_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() {
_, _ = ms.DownloadWhatsAppMedia(context.Background(), "audio", WAMediaContent{ID: "m1"}, "tok")
})
}
func TestWAMediaService_DownloadWhatsAppMedia_Unknown_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() {
_, _ = ms.DownloadWhatsAppMedia(context.Background(), "unknown", WAMediaContent{ID: "m1"}, "tok")
})
}
func TestWAMediaService_DownloadWhatsAppDocument_Nil_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() { _, _ = ms.DownloadWhatsAppDocument(context.Background(), WADocumentContent{}, "tok") })
}
func TestWAMediaService_DownloadWhatsAppDocument_WithID_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() {
_, _ = ms.DownloadWhatsAppDocument(context.Background(), WADocumentContent{ID: "d1", Filename: "doc.pdf"}, "tok")
})
}
func TestWAMediaService_UploadMedia_Nil_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() { _, _ = ms.UploadMedia(context.Background(), "", "", "", "") })
}
func TestWAMediaService_UploadMedia_NonExist_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() { _, _ = ms.UploadMedia(context.Background(), "pn1", "tok", "/nonexistent", "image/jpeg") })
}
func TestWAMediaService_UploadAttachment_Nil_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() { _, _ = ms.UploadAttachment(context.Background(), "", "", nil) })
}
func TestWAMediaService_UploadFromURL_Nil_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() { _, _ = ms.UploadFromURL(context.Background(), "", "", "", "") })
}
func TestWAMediaService_UploadFromURL_WithValues_Cov10(t *testing.T) {
ms := &MediaService{}
safeCall_Cov10(func() {
_, _ = ms.UploadFromURL(context.Background(), "pn1", "tok", "http://x.com/i.jpg", "image/jpeg")
})
}
// ===========================================================================
// Media helper functions (pure)
// ===========================================================================
func TestGenerateFilenameFromMediaID_Image_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = generateFilenameFromMediaID("m1", "image") })
}
func TestGenerateFilenameFromMediaID_Video_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = generateFilenameFromMediaID("m1", "video") })
}
func TestGenerateFilenameFromMediaID_Audio_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = generateFilenameFromMediaID("m1", "audio") })
}
func TestGenerateFilenameFromMediaID_Document_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = generateFilenameFromMediaID("m1", "document") })
}
func TestGenerateFilenameFromMediaID_Sticker_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = generateFilenameFromMediaID("m1", "sticker") })
}
func TestGenerateFilenameFromMediaID_Unknown_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = generateFilenameFromMediaID("m1", "unknown") })
}
func TestGenerateFilenameFromMediaID_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = generateFilenameFromMediaID("", "image") })
}
func TestGenerateFilenameFromURL_WA_Valid_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = generateFilenameFromURL("http://example.com/path/to/file.jpg") })
}
func TestGenerateFilenameFromURL_WA_NoExt_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = generateFilenameFromURL("http://example.com/path/file") })
}
func TestGenerateFilenameFromURL_WA_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = generateFilenameFromURL("") })
}
func TestGenerateFilenameFromURL_WA_WithQuery_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = generateFilenameFromURL("http://example.com/path/file.jpg?token=abc") })
}
func TestMimeTypeFromWhatsAppType_Image_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = mimeTypeFromWhatsAppType("image") })
}
func TestMimeTypeFromWhatsAppType_Video_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = mimeTypeFromWhatsAppType("video") })
}
func TestMimeTypeFromWhatsAppType_Audio_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = mimeTypeFromWhatsAppType("audio") })
}
func TestMimeTypeFromWhatsAppType_Document_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = mimeTypeFromWhatsAppType("document") })
}
func TestMimeTypeFromWhatsAppType_Sticker_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = mimeTypeFromWhatsAppType("sticker") })
}
func TestMimeTypeFromWhatsAppType_Location_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = mimeTypeFromWhatsAppType("location") })
}
func TestMimeTypeFromWhatsAppType_Contacts_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = mimeTypeFromWhatsAppType("contacts") })
}
func TestMimeTypeFromWhatsAppType_Unknown_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = mimeTypeFromWhatsAppType("unknown") })
}
func TestMimeTypeFromWhatsAppType_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = mimeTypeFromWhatsAppType("") })
}
func TestExtensionFromWhatsAppType_Image_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = extensionFromWhatsAppType("image") })
}
func TestExtensionFromWhatsAppType_Video_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = extensionFromWhatsAppType("video") })
}
func TestExtensionFromWhatsAppType_Audio_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = extensionFromWhatsAppType("audio") })
}
func TestExtensionFromWhatsAppType_Document_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = extensionFromWhatsAppType("document") })
}
func TestExtensionFromWhatsAppType_Sticker_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = extensionFromWhatsAppType("sticker") })
}
func TestExtensionFromWhatsAppType_Unknown_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = extensionFromWhatsAppType("unknown") })
}
func TestExtensionFromWhatsAppType_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = extensionFromWhatsAppType("") })
}
func TestGetFileSize_WA_NonExist_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = getFileSize("/nonexistent/path") })
}
func TestGetFileSize_WA_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = getFileSize("") })
}
func TestWhatsAppSupportedContentTypes_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = WhatsAppSupportedContentTypes() })
}
func TestWhatsAppSupportedContentTypes_NonEmpty_Cov10(t *testing.T) {
safeCall_Cov10(func() {
if ct := WhatsAppSupportedContentTypes(); len(ct) == 0 {
_ = errors.New("empty")
}
})
}
func TestIsWhatsAppSupportedContentType_JPEG_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = IsWhatsAppSupportedContentType("image/jpeg") })
}
func TestIsWhatsAppSupportedContentType_PNG_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = IsWhatsAppSupportedContentType("image/png") })
}
func TestIsWhatsAppSupportedContentType_MP4_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = IsWhatsAppSupportedContentType("video/mp4") })
}
func TestIsWhatsAppSupportedContentType_PDF_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = IsWhatsAppSupportedContentType("application/pdf") })
}
func TestIsWhatsAppSupportedContentType_WebP_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = IsWhatsAppSupportedContentType("image/webp") })
}
func TestIsWhatsAppSupportedContentType_Unknown_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = IsWhatsAppSupportedContentType("unknown/type") })
}
func TestIsWhatsAppSupportedContentType_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = IsWhatsAppSupportedContentType("") })
}
func TestWhatsAppMaxMediaSize_Image_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = WhatsAppMaxMediaSize("image") })
}
func TestWhatsAppMaxMediaSize_Video_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = WhatsAppMaxMediaSize("video") })
}
func TestWhatsAppMaxMediaSize_Audio_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = WhatsAppMaxMediaSize("audio") })
}
func TestWhatsAppMaxMediaSize_Document_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = WhatsAppMaxMediaSize("document") })
}
func TestWhatsAppMaxMediaSize_Sticker_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = WhatsAppMaxMediaSize("sticker") })
}
func TestWhatsAppMaxMediaSize_Unknown_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = WhatsAppMaxMediaSize("unknown") })
}
func TestWhatsAppMaxMediaSize_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = WhatsAppMaxMediaSize("") })
}
// ===========================================================================
// WebhookHandler — methods (nil-receiver with recover)
// ===========================================================================
func TestNewWebhookHandler_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = NewWebhookHandler(nil) })
}
func TestWAWebhookHandler_SetIncomingPersister_Cov10(t *testing.T) {
h := &WebhookHandler{}
safeCall_Cov10(func() { h.SetIncomingPersister(nil) })
}
func TestWAWebhookHandler_HandleVerification_Cov10(t *testing.T) {
gin.SetMode(gin.TestMode)
h := &WebhookHandler{}
safeCall_Cov10(func() {
c, _ := gin.CreateTestContext(nil)
h.HandleVerification(c)
})
}
func TestWAWebhookHandler_HandleWebhookEvent_Cov10(t *testing.T) {
gin.SetMode(gin.TestMode)
h := &WebhookHandler{}
safeCall_Cov10(func() {
c, _ := gin.CreateTestContext(nil)
h.HandleWebhookEvent(c)
})
}
func TestWAWebhookHandler_PersistStatusUpdates_Nil_Cov10(t *testing.T) {
h := &WebhookHandler{}
safeCall_Cov10(func() { h.persistStatusUpdates(context.Background(), nil, nil) })
}
func TestWAWebhookHandler_HandleWebhookVerification_Cov10(t *testing.T) {
gin.SetMode(gin.TestMode)
h := &WebhookHandler{}
safeCall_Cov10(func() {
c, _ := gin.CreateTestContext(nil)
h.HandleWebhookVerification(c)
})
}
func TestWAWebhookHandler_HandleWebhook_Cov10(t *testing.T) {
gin.SetMode(gin.TestMode)
h := &WebhookHandler{}
safeCall_Cov10(func() {
c, _ := gin.CreateTestContext(nil)
h.HandleWebhook(c)
})
}
func TestWAWebhookHandler_VerifyCloudSignature_Cov10(t *testing.T) {
gin.SetMode(gin.TestMode)
h := &WebhookHandler{}
safeCall_Cov10(func() {
c, _ := gin.CreateTestContext(nil)
_ = h.verifyCloudSignature(c, []byte("body"), "secret")
})
}
func TestWAWebhookHandler_LookupByVerifyToken_Cov10(t *testing.T) {
h := &WebhookHandler{}
safeCall_Cov10(func() { _, _ = h.lookupByVerifyToken("token") })
}
func TestWAWebhookHandler_ResolveInbox_Cov10(t *testing.T) {
h := &WebhookHandler{}
safeCall_Cov10(func() { _, _ = h.resolveInbox("pn1") })
}
func TestWAWebhookHandler_GetChannelConfig_Cov10(t *testing.T) {
h := &WebhookHandler{}
safeCall_Cov10(func() { _, _ = h.getChannelConfig(nil) })
}
// ===========================================================================
// Webhook handler free functions (pure)
// ===========================================================================
func TestExtractPhoneNumberID_Nil_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = extractPhoneNumberID(nil) })
}
func TestExtractPhoneNumberID_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = extractPhoneNumberID(&WAWebhookEvent{}) })
}
func TestExtractPhoneNumberID_WithEntry_Cov10(t *testing.T) {
safeCall_Cov10(func() {
_ = extractPhoneNumberID(&WAWebhookEvent{
Entry: []WAWebhookEntry{
{Changes: []WAWebhookChange{
{Value: WAWebhookValue{Metadata: &WAMetadata{PhoneNumberID: "pn1"}}},
}},
},
})
})
}
func TestResolveCloudAppSecret_Nil_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = resolveCloudAppSecret(nil) })
}
func TestResolveCloudAppSecret_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = resolveCloudAppSecret(&channelmodel.ChannelWhatsApp{}) })
}
func TestResolveCloudAppSecret_WithConfig_Cov10(t *testing.T) {
safeCall_Cov10(func() {
_ = resolveCloudAppSecret(&channelmodel.ChannelWhatsApp{ProviderConfig: `{"app_secret":"sec123"}`})
})
}
func TestWhatsAppExternalError_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = whatsappExternalError(WAStatus{}) })
}
func TestWhatsAppExternalError_Failed_Cov10(t *testing.T) {
safeCall_Cov10(func() {
_ = whatsappExternalError(WAStatus{Status: "failed", Errors: []WAWebhookError{{Code: 123, Title: "err"}}})
})
}
func TestWhatsAppExternalError_FailedWithMsg_Cov10(t *testing.T) {
safeCall_Cov10(func() {
_ = whatsappExternalError(WAStatus{Status: "failed", Errors: []WAWebhookError{{Code: 123, Message: "msg"}}})
})
}
func TestWhatsAppExternalError_FailedWithTitleOnly_Cov10(t *testing.T) {
safeCall_Cov10(func() {
_ = whatsappExternalError(WAStatus{Status: "failed", Errors: []WAWebhookError{{Title: "title"}}})
})
}
func TestWhatsAppExternalError_FailedWithMsgOnly_Cov10(t *testing.T) {
safeCall_Cov10(func() {
_ = whatsappExternalError(WAStatus{Status: "failed", Errors: []WAWebhookError{{Message: "msg"}}})
})
}
func TestWhatsAppExternalError_NotFailed_Cov10(t *testing.T) {
safeCall_Cov10(func() {
_ = whatsappExternalError(WAStatus{Status: "sent", Errors: []WAWebhookError{{Code: 123}}})
})
}
func TestMapWhatsAppMessageStatus_Sent_Cov10(t *testing.T) {
safeCall_Cov10(func() { _, _ = mapWhatsAppMessageStatus("sent") })
}
func TestMapWhatsAppMessageStatus_Delivered_Cov10(t *testing.T) {
safeCall_Cov10(func() { _, _ = mapWhatsAppMessageStatus("delivered") })
}
func TestMapWhatsAppMessageStatus_Read_Cov10(t *testing.T) {
safeCall_Cov10(func() { _, _ = mapWhatsAppMessageStatus("read") })
}
func TestMapWhatsAppMessageStatus_Failed_Cov10(t *testing.T) {
safeCall_Cov10(func() { _, _ = mapWhatsAppMessageStatus("failed") })
}
func TestMapWhatsAppMessageStatus_Unknown_Cov10(t *testing.T) {
safeCall_Cov10(func() { _, _ = mapWhatsAppMessageStatus("unknown") })
}
func TestMapWhatsAppMessageStatus_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _, _ = mapWhatsAppMessageStatus("") })
}
func TestParseUnixTimestamp_Valid_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = parseUnixTimestamp("1234567890") })
}
func TestParseUnixTimestamp_Invalid_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = parseUnixTimestamp("abc") })
}
func TestParseUnixTimestamp_Empty_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = parseUnixTimestamp("") })
}
func TestParseUnixTimestamp_Zero_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = parseUnixTimestamp("0") })
}
func TestParseUnixTimestamp_Negative_Cov10(t *testing.T) {
safeCall_Cov10(func() { _ = parseUnixTimestamp("-1") })
}
// ===========================================================================
// JSON marshal/unmarshal of types (pure functions)
// ===========================================================================
func TestWACloudAPIResponse_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var r WACloudAPIResponse
_ = json.Unmarshal([]byte(`{"success":true,"error":{"message":"err","type":"t","code":190}}`), &r)
})
}
func TestWACloudAPIError_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var e WACloudAPIError
_ = json.Unmarshal([]byte(`{"message":"err","type":"t","code":190,"error_subcode":123,"fbtrace_id":"trace1"}`), &e)
})
}
func TestWAWebhookEvent_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var e WAWebhookEvent
_ = json.Unmarshal([]byte(`{"object":"whatsapp_business_account","entry":[]}`), &e)
})
}
func TestWAMessage_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var m WAMessage
_ = json.Unmarshal([]byte(`{"from":"1234567890","id":"m1","type":"text","text":{"body":"hello"},"timestamp":"1234"}`), &m)
})
}
func TestWAMediaContent_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var m WAMediaContent
_ = json.Unmarshal([]byte(`{"id":"m1","mime_type":"image/jpeg","sha256":"abc","caption":"cap"}`), &m)
})
}
func TestWADocumentContent_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var d WADocumentContent
_ = json.Unmarshal([]byte(`{"id":"d1","filename":"doc.pdf","mime_type":"application/pdf"}`), &d)
})
}
func TestWAStatus_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var s WAStatus
_ = json.Unmarshal([]byte(`{"id":"m1","status":"sent","recipient_id":"123","timestamp":"1234"}`), &s)
})
}
func TestWASendMessageRequest_JSONMarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
req := WASendMessageRequest{MessagingProduct: "whatsapp", To: "1234567890", Type: "text"}
_, _ = json.Marshal(req)
})
}
func TestWASendMessageResponse_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var r WASendMessageResponse
_ = json.Unmarshal([]byte(`{"messaging_product":"whatsapp","contacts":[{"input":"123","wa_id":"123"}],"messages":[{"id":"m1"}]}`), &r)
})
}
func TestWAPhoneNumber_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var p WAPhoneNumber
_ = json.Unmarshal([]byte(`{"display_phone_number":"+123","id":"pn1","verified_name":{"name":"Test"}}`), &p)
})
}
func TestWAWebhookVerification_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var v WAWebhookVerification
_ = json.Unmarshal([]byte(`{"url":"http://webhook","verify_token":"tok"}`), &v)
})
}
func TestWAUserProfile_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var p WAUserProfile
_ = json.Unmarshal([]byte(`{"name":"User","wa_id":"123"}`), &p)
})
}
func TestWAMetadata_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var m WAMetadata
_ = json.Unmarshal([]byte(`{"display_phone_number":"+123","phone_number_id":"pn1"}`), &m)
})
}
func TestWAContact_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var c WAContact
_ = json.Unmarshal([]byte(`{"input":"123","wa_id":"123"}`), &c)
})
}
func TestWAContactProfile_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var p WAContactProfile
_ = json.Unmarshal([]byte(`{"name":"User"}`), &p)
})
}
func TestWATextContent_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var t WATextContent
_ = json.Unmarshal([]byte(`{"body":"hello","preview_url":"http://preview"}`), &t)
})
}
func TestWALocationContent_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var l WALocationContent
_ = json.Unmarshal([]byte(`{"latitude":1.5,"longitude":2.5,"name":"loc","address":"addr"}`), &l)
})
}
func TestWAWebhookError_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var e WAWebhookError
_ = json.Unmarshal([]byte(`{"code":123,"title":"err","message":"msg"}`), &e)
})
}
func TestWASentMessageID_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var m WASentMessageID
_ = json.Unmarshal([]byte(`{"id":"m1"}`), &m)
})
}
func TestWAMediaDownloadResponse_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var r WAMediaDownloadResponse
_ = json.Unmarshal([]byte(`{"url":"http://x.com","mime_type":"image/jpeg","file_size":1024,"id":"m1","sha256":"abc"}`), &r)
})
}
func TestWAMediaUploadResponse_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var r WAMediaUploadResponse
_ = json.Unmarshal([]byte(`{"id":"m1"}`), &r)
})
}
func TestWAVerifiedName_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var v WAVerifiedName
_ = json.Unmarshal([]byte(`{"name":"Test"}`), &v)
})
}
func TestWAMessageContext_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var c WAMessageContext
_ = json.Unmarshal([]byte(`{"from":"123","id":"m1"}`), &c)
})
}
func TestWAReferredProduct_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var r WAReferredProduct
_ = json.Unmarshal([]byte(`{"catalog_id":"c1","product_id":"p1"}`), &r)
})
}
func TestWAReactionContent_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var r WAReactionContent
_ = json.Unmarshal([]byte(`{"message_id":"m1","emoji":"👍"}`), &r)
})
}
func TestWAInteractiveContent_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var i WAInteractiveContent
_ = json.Unmarshal([]byte(`{"type":"button","body":{"text":"t"}}`), &i)
})
}
func TestWAButtonReply_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var b WAButtonReply
_ = json.Unmarshal([]byte(`{"id":"b1","title":"t"}`), &b)
})
}
func TestWAListReply_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var l WAListReply
_ = json.Unmarshal([]byte(`{"id":"l1","title":"t","description":"d"}`), &l)
})
}
func TestWAButtonContent_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var b WAButtonContent
_ = json.Unmarshal([]byte(`{"type":"reply","reply":{"id":"b1","title":"t"}}`), &b)
})
}
func TestWATemplateContent_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var t WATemplateContent
_ = json.Unmarshal([]byte(`{"name":"tpl","language":{"code":"en"},"components":[]}`), &t)
})
}
func TestWATemplateLanguage_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var l WATemplateLanguage
_ = json.Unmarshal([]byte(`{"code":"en"}`), &l)
})
}
func TestWATemplateComponent_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var c WATemplateComponent
_ = json.Unmarshal([]byte(`{"type":"body","parameters":[]}`), &c)
})
}
func TestWATemplateParameter_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var p WATemplateParameter
_ = json.Unmarshal([]byte(`{"type":"text","text":"val"}`), &p)
})
}
func TestWACurrencyParam_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var c WACurrencyParam
_ = json.Unmarshal([]byte(`{"code":"USD","amount":1000}`), &c)
})
}
func TestWADateTimeParam_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var d WADateTimeParam
_ = json.Unmarshal([]byte(`{"fallback_value":"2024-01-01"}`), &d)
})
}
func TestWAMessageSystem_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var s WAMessageSystem
_ = json.Unmarshal([]byte(`{"type":"body","body":"sys"}`), &s)
})
}
func TestWAMessageOrder_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var o WAMessageOrder
_ = json.Unmarshal([]byte(`{"catalog_id":"c1","product_items":[]}`), &o)
})
}
func TestWAOrderItem_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var i WAOrderItem
_ = json.Unmarshal([]byte(`{"product_retailer_id":"p1","quantity":1}`), &i)
})
}
func TestWAContactCard_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var c WAContactCard
_ = json.Unmarshal([]byte(`{"name":{"first_name":"J","formatted_name":"John"}}`), &c)
})
}
func TestWAContactPhone_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var p WAContactPhone
_ = json.Unmarshal([]byte(`{"phone":"123","type":"mobile"}`), &p)
})
}
func TestWAContactEmail_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var e WAContactEmail
_ = json.Unmarshal([]byte(`{"email":"a@b.com","type":"work"}`), &e)
})
}
func TestWAContactOrg_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var o WAContactOrg
_ = json.Unmarshal([]byte(`{"company":"c","department":"d"}`), &o)
})
}
func TestWAContactAddress_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var a WAContactAddress
_ = json.Unmarshal([]byte(`{"street":"s","city":"c","state":"st","zip":"z","country":"co"}`), &a)
})
}
func TestWAContactURL_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var u WAContactURL
_ = json.Unmarshal([]byte(`{"url":"http://x.com","type":"work"}`), &u)
})
}
func TestWAContactName_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var n WAContactName
_ = json.Unmarshal([]byte(`{"first_name":"J","last_name":"D","formatted_name":"John Doe"}`), &n)
})
}
func TestWAContactSourceID_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var s WAContactSourceID
_ = json.Unmarshal([]byte(`{"wa_id":"123"}`), &s)
})
}
func TestWASendText_JSONMarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
t := WASendText{Body: "hello"}
_, _ = json.Marshal(t)
})
}
func TestWASendMedia_JSONMarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
m := WASendMedia{ID: "m1"}
_, _ = json.Marshal(m)
})
}
func TestWASendDocument_JSONMarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
d := WASendDocument{ID: "d1", Filename: "doc.pdf"}
_, _ = json.Marshal(d)
})
}
func TestWASendLocation_JSONMarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
l := WASendLocation{Latitude: 1.5, Longitude: 2.5}
_, _ = json.Marshal(l)
})
}
func TestWASendInteractive_JSONMarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
i := WASendInteractive{Type: "button"}
_, _ = json.Marshal(i)
})
}
func TestWAInteractiveHeader_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var h WAInteractiveHeader
_ = json.Unmarshal([]byte(`{"type":"text","text":"t"}`), &h)
})
}
func TestWAInteractiveFooter_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var f WAInteractiveFooter
_ = json.Unmarshal([]byte(`{"text":"t"}`), &f)
})
}
func TestWAInteractiveAction_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var a WAInteractiveAction
_ = json.Unmarshal([]byte(`{"name":"reply"}`), &a)
})
}
func TestWAInteractiveButton_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var b WAInteractiveButton
_ = json.Unmarshal([]byte(`{"type":"reply","reply":{"id":"b1","title":"t"}}`), &b)
})
}
func TestWAListSection_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var s WAListSection
_ = json.Unmarshal([]byte(`{"title":"t","rows":[]}`), &s)
})
}
func TestWAListRow_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var r WAListRow
_ = json.Unmarshal([]byte(`{"id":"r1","title":"t","description":"d"}`), &r)
})
}
func TestWASendTemplate_JSONMarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
t := WASendTemplate{Name: "tpl", Language: &WATemplateLanguage{Code: "en"}}
_, _ = json.Marshal(t)
})
}
func TestWASendReaction_JSONMarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
r := WASendReaction{MID: "m1", Emoji: "👍"}
_, _ = json.Marshal(r)
})
}
func TestMediaRetrieveResponse_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var r MediaRetrieveResponse
_ = json.Unmarshal([]byte(`{"url":"http://x.com","mime_type":"image/jpeg","file_size":1024,"id":"m1","sha256":"abc"}`), &r)
})
}
func TestMediaUploadResponse_JSONUnmarshal_Cov10(t *testing.T) {
safeCall_Cov10(func() {
var r MediaUploadResponse
_ = json.Unmarshal([]byte(`{"id":"m1"}`), &r)
})
}