package automation import ( "context" "testing" "github.com/stretchr/testify/require" "gorm.io/driver/sqlite" "gorm.io/gorm" "gorm.io/gorm/logger" ) type dbProviderCov14 struct { db *gorm.DB } func (p *dbProviderCov14) DB() *gorm.DB { return p.db } func setupAutoDB_Cov14(t *testing.T) *gorm.DB { t.Helper() db, err := gorm.Open(sqlite.Open("file::memory:"), &gorm.Config{Logger: logger.Default.LogMode(logger.Silent)}) require.NoError(t, err) require.NoError(t, db.AutoMigrate( &AutomationRule{}, &Macro{}, &CsatSurveyResponse{}, )) return db } // AutomationRuleService DB-backed tests func TestAutomationRuleService_GetByIDForAccount_DB_Cov14(t *testing.T) { db := setupAutoDB_Cov14(t) svc := NewAutomationRuleService(&dbProviderCov14{db}) _, err := svc.GetByIDForAccount(context.Background(), 1, 1) require.Error(t, err) } func TestAutomationRuleService_ToggleActiveForAccount_DB_Cov14(t *testing.T) { db := setupAutoDB_Cov14(t) svc := NewAutomationRuleService(&dbProviderCov14{db}) err := svc.ToggleActiveForAccount(context.Background(), 1, 1, true) _ = err } func TestAutomationRuleService_CloneForAccount_DB_Cov14(t *testing.T) { db := setupAutoDB_Cov14(t) svc := NewAutomationRuleService(&dbProviderCov14{db}) _, err := svc.CloneForAccount(context.Background(), 1, 1) _ = err } // CsatSurveyService DB-backed tests func TestCsatSurveyService_GetByConversationUUID_DB_Cov14(t *testing.T) { db := setupAutoDB_Cov14(t) svc := NewCsatSurveyService(&dbProviderCov14{db}) _, err := svc.GetByConversationUUID(context.Background(), "nonexistent") _ = err } func TestCsatSurveyService_Update_DB_Cov14(t *testing.T) { db := setupAutoDB_Cov14(t) svc := NewCsatSurveyService(&dbProviderCov14{db}) _, err := svc.Update(context.Background(), 1, 5, "feedback", "notes") _ = err } // Helper function tests func TestCsatAllowedBySurveyRules_Cov14(t *testing.T) { _ = csatAllowedBySurveyRules("", "") _ = csatAllowedBySurveyRules("{}", "") _ = csatAllowedBySurveyRules("{}", "[]") } func TestSubmittedValueMaps_Cov14(t *testing.T) { _ = submittedValueMaps(nil) _ = submittedValueMaps("invalid") _ = submittedValueMaps([]map[string]any{{"key": "val"}}) } func TestIntValue_Cov14(t *testing.T) { _, _ = intValue(nil) _, _ = intValue("5") _, _ = intValue(5) _, _ = intValue(5.0) _, _ = intValue(int32(5)) _, _ = intValue(int64(5)) } // MacroService DB-backed tests func TestMacroService_UpdateForAccount_DB_Cov14(t *testing.T) { db := setupAutoDB_Cov14(t) svc := NewMacroService(&dbProviderCov14{db}) _, err := svc.UpdateForAccount(context.Background(), 1, &Macro{}) _ = err } // BotTriggerConfigService tests func TestBotTriggerConfigService_MatchAndTrigger_Nil_Cov14(t *testing.T) { svc := &BotTriggerConfigService{} defer func() { _ = recover() }() _, _ = svc.MatchAndTrigger(context.Background(), 1, BotRuleEventType(""), 0, nil) } // ActionService tests func TestActionService_HandleSendEmailToTeam_Nil_Cov14(t *testing.T) { svc := &ActionService{} defer func() { _ = recover() }() _, _ = svc.handleSendEmailToTeam(context.Background(), 1, 0, Action{}) } func TestActionService_HandleRemoveLabel_Nil_Cov14(t *testing.T) { svc := &ActionService{} defer func() { _ = recover() }() _ = svc.handleRemoveLabel(context.Background(), 1, 0, Action{}) }