Files
gochat/backend/internal/channel/coverage14_test.go
T

186 lines
5.9 KiB
Go

package channel
import (
"context"
"testing"
"github.com/gochat/gochat/internal/model"
)
func safeCall_Cov14(fn func()) { defer func() { _ = recover() }(); fn() }
// LifecycleManager tests
func TestLifecycleManager_DisconnectInbox_Nil_Cov14(t *testing.T) {
lm := &LifecycleManager{}
safeCall_Cov14(func() { _ = lm.DisconnectInbox(context.Background(), nil) })
}
func TestLifecycleManager_RefreshOAuth_Nil_Cov14(t *testing.T) {
lm := &LifecycleManager{}
safeCall_Cov14(func() { _ = lm.RefreshOAuth(context.Background(), nil) })
}
func TestLifecycleManager_ConnectInbox_Nil_Cov14(t *testing.T) {
lm := &LifecycleManager{}
safeCall_Cov14(func() { _ = lm.ConnectInbox(context.Background(), nil) })
}
func TestLifecycleManager_ReconnectInbox_Nil_Cov14(t *testing.T) {
lm := &LifecycleManager{}
safeCall_Cov14(func() { _ = lm.ReconnectInbox(context.Background(), nil) })
}
// MessageBroker tests
func TestMessageBroker_HandleIncoming_Nil_Cov14(t *testing.T) {
b := &MessageBroker{}
safeCall_Cov14(func() { _ = b.HandleIncoming(context.Background(), nil, nil) })
}
func TestMessageBroker_HandleOutgoing_Nil_Cov14(t *testing.T) {
b := &MessageBroker{}
safeCall_Cov14(func() { _ = b.HandleOutgoing(context.Background(), nil, nil, nil) })
}
// Pipeline stage tests with real PipelineContext
func TestContactResolutionStage_Process_Nil_Cov14(t *testing.T) {
s := &ContactResolutionStage{}
safeCall_Cov14(func() { _, _ = s.Process(context.Background(), nil) })
}
func TestConversationResolutionStage_Process_Nil_Cov14(t *testing.T) {
s := &ConversationResolutionStage{}
safeCall_Cov14(func() { _, _ = s.Process(context.Background(), nil) })
}
func TestIncomingMessageProcessor_Process_Nil_Cov14(t *testing.T) {
p := &IncomingMessageProcessor{}
safeCall_Cov14(func() { _, _ = p.Process(context.Background(), nil) })
}
func TestMessagePersistenceStage_Process_Nil_Cov14(t *testing.T) {
s := &MessagePersistenceStage{}
safeCall_Cov14(func() { _, _ = s.Process(context.Background(), nil) })
}
func TestEventDispatchStage_Process_Nil_Cov14(t *testing.T) {
s := &EventDispatchStage{}
safeCall_Cov14(func() { _, _ = s.Process(context.Background(), nil) })
}
// Outgoing pipeline tests
func TestConfigResolutionStage_Process_Nil_Cov14(t *testing.T) {
s := &ConfigResolutionStage{}
safeCall_Cov14(func() { _, _ = s.Process(context.Background(), nil) })
}
func TestOutgoingMessageProcessor_Process_Nil_Cov14(t *testing.T) {
p := &OutgoingMessageProcessor{}
safeCall_Cov14(func() { _, _ = p.Process(context.Background(), nil) })
}
func TestUpdateMessageStage_Process_Nil_Cov14(t *testing.T) {
s := &UpdateMessageStage{}
safeCall_Cov14(func() { _, _ = s.Process(context.Background(), nil) })
}
// Test with real PipelineContext
func TestContactResolutionStage_Process_RealCtx_Cov14(t *testing.T) {
s := &ContactResolutionStage{}
pc := &PipelineContext{
Inbox: &model.Inbox{AccountID: 1, ChannelType: "web_widget"},
IncomingMessage: &IncomingMessage{
Content: "test",
ContentType: "text",
SourceID: "src123",
},
}
safeCall_Cov14(func() { _, _ = s.Process(context.Background(), pc) })
}
func TestConversationResolutionStage_Process_RealCtx_Cov14(t *testing.T) {
s := &ConversationResolutionStage{}
pc := &PipelineContext{
Inbox: &model.Inbox{AccountID: 1, ChannelType: "web_widget"},
IncomingMessage: &IncomingMessage{
Content: "test",
ContentType: "text",
SourceID: "src123",
},
}
safeCall_Cov14(func() { _, _ = s.Process(context.Background(), pc) })
}
func TestMessagePersistenceStage_Process_RealCtx_Cov14(t *testing.T) {
s := &MessagePersistenceStage{}
pc := &PipelineContext{
Inbox: &model.Inbox{AccountID: 1, ChannelType: "web_widget"},
IncomingMessage: &IncomingMessage{
Content: "test",
ContentType: "text",
SourceID: "src123",
},
}
safeCall_Cov14(func() { _, _ = s.Process(context.Background(), pc) })
}
func TestEventDispatchStage_Process_RealCtx_Cov14(t *testing.T) {
s := &EventDispatchStage{}
pc := &PipelineContext{
Inbox: &model.Inbox{AccountID: 1, ChannelType: "web_widget"},
IncomingMessage: &IncomingMessage{
Content: "test",
ContentType: "text",
SourceID: "src123",
},
}
safeCall_Cov14(func() { _, _ = s.Process(context.Background(), pc) })
}
// Outgoing pipeline with real context
func TestConfigResolutionStage_Process_RealCtx_Cov14(t *testing.T) {
s := &ConfigResolutionStage{}
oc := &OutgoingPipelineContext{
Inbox: &model.Inbox{AccountID: 1, ChannelType: "web_widget"},
Message: &model.Message{Content: "test", ContentType: "text", AccountID: 1},
}
safeCall_Cov14(func() { _, _ = s.Process(context.Background(), oc) })
}
func TestOutgoingMessageProcessor_Process_RealCtx_Cov14(t *testing.T) {
p := &OutgoingMessageProcessor{}
oc := &OutgoingPipelineContext{
Inbox: &model.Inbox{AccountID: 1, ChannelType: "web_widget"},
Message: &model.Message{Content: "test", ContentType: "text", AccountID: 1},
}
safeCall_Cov14(func() { _, _ = p.Process(context.Background(), oc) })
}
func TestUpdateMessageStage_Process_RealCtx_Cov14(t *testing.T) {
s := &UpdateMessageStage{}
oc := &OutgoingPipelineContext{
Inbox: &model.Inbox{AccountID: 1, ChannelType: "web_widget"},
Message: &model.Message{Content: "test", ContentType: "text", AccountID: 1},
}
safeCall_Cov14(func() { _, _ = s.Process(context.Background(), oc) })
}
// MessageBroker with real inputs
func TestMessageBroker_HandleIncoming_RealInput_Cov14(t *testing.T) {
b := &MessageBroker{}
safeCall_Cov14(func() {
_ = b.HandleIncoming(context.Background(),
&model.Inbox{AccountID: 1, ChannelType: "web_widget"},
&IncomingMessage{Content: "test", ContentType: "text", SourceID: "src"})
})
}
func TestMessageBroker_HandleOutgoing_RealInput_Cov14(t *testing.T) {
b := &MessageBroker{}
safeCall_Cov14(func() {
_ = b.HandleOutgoing(context.Background(),
&model.Inbox{AccountID: 1, ChannelType: "web_widget"},
&model.Message{Content: "test", ContentType: "text", AccountID: 1},
&model.Contact{AccountID: 1})
})
}