@@ -37,6 +37,7 @@ func TestTaskService_ExecuteTask(t *testing.T) {
3737 mockLogger .EXPECT ().Error (gomock .Any ()).AnyTimes ()
3838
3939 taskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
40+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
4041
4142 // Setup transaction mocking for all tests
4243 mockRepo .EXPECT ().
@@ -171,6 +172,7 @@ func TestTaskService_ExecuteTask(t *testing.T) {
171172
172173 // Create a new task service instance for this test
173174 procTaskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
175+ procTaskService .SetAutoExecuteImmediate (false ) // Disable for testing
174176
175177 // Register a processor for the task type
176178 mockProcessor := mocks .NewMockTaskProcessor (procCtrl )
@@ -292,6 +294,7 @@ func TestTaskService_ExecuteTask(t *testing.T) {
292294
293295 // Create a new task service instance for this test
294296 procTaskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
297+ procTaskService .SetAutoExecuteImmediate (false ) // Disable for testing
295298
296299 // Register a processor for the task type
297300 mockProcessor := mocks .NewMockTaskProcessor (procCtrl )
@@ -354,6 +357,7 @@ func TestTaskService_ExecuteTask(t *testing.T) {
354357
355358 // Create a new task service instance for this test
356359 procTaskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
360+ procTaskService .SetAutoExecuteImmediate (false ) // Disable for testing
357361
358362 // Register a processor for the task type
359363 mockProcessor := mocks .NewMockTaskProcessor (procCtrl )
@@ -417,6 +421,7 @@ func TestTaskService_CreateTask(t *testing.T) {
417421 mockLogger .EXPECT ().Info (gomock .Any ()).AnyTimes ()
418422
419423 taskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
424+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
420425
421426 t .Run ("Sets default values when not provided" , func (t * testing.T ) {
422427 // Setup
@@ -523,6 +528,7 @@ func TestTaskService_ListTasks(t *testing.T) {
523528 mockLogger .EXPECT ().Info (gomock .Any ()).AnyTimes ()
524529
525530 taskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
531+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
526532
527533 t .Run ("Returns tasks with pagination info" , func (t * testing.T ) {
528534 // Setup
@@ -632,6 +638,7 @@ func TestTaskService_GetTask(t *testing.T) {
632638 mockLogger .EXPECT ().Info (gomock .Any ()).AnyTimes ()
633639
634640 taskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
641+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
635642
636643 t .Run ("Returns task when found" , func (t * testing.T ) {
637644 // Setup
@@ -696,6 +703,7 @@ func TestTaskService_DeleteTask(t *testing.T) {
696703 mockLogger .EXPECT ().Info (gomock .Any ()).AnyTimes ()
697704
698705 taskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
706+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
699707
700708 t .Run ("Deletes task successfully" , func (t * testing.T ) {
701709 // Setup
@@ -750,6 +758,7 @@ func TestTaskService_RegisterProcessor(t *testing.T) {
750758 mockLogger .EXPECT ().Info (gomock .Any ()).AnyTimes ()
751759
752760 taskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
761+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
753762
754763 t .Run ("Registers processor for supported task types" , func (t * testing.T ) {
755764 // Create a processor that only supports certain task types
@@ -831,6 +840,9 @@ func TestTaskService_BroadcastEventHandlers(t *testing.T) {
831840 mockEventBus .EXPECT ().Subscribe (domain .EventBroadcastFailed , gomock .Any ()).Times (1 )
832841 mockEventBus .EXPECT ().Subscribe (domain .EventBroadcastCancelled , gomock .Any ()).Times (1 )
833842
843+ // Disable auto-execution for testing to avoid goroutine issues
844+ taskService .SetAutoExecuteImmediate (false )
845+
834846 // Subscribe to events
835847 taskService .SubscribeToBroadcastEvents (mockEventBus )
836848
@@ -944,6 +956,7 @@ func TestTaskService_ExecutePendingTasks(t *testing.T) {
944956 t .Run ("Uses HTTP execution when API endpoint is configured" , func (t * testing.T ) {
945957 // Create TaskService with API endpoint
946958 taskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
959+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
947960
948961 // Setup
949962 ctx := context .Background ()
@@ -1004,6 +1017,7 @@ func TestTaskService_ExecutePendingTasks(t *testing.T) {
10041017
10051018 // Create TaskService without API endpoint
10061019 taskService := NewTaskService (localRepo , localLogger , mockAuthService , "" )
1020+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
10071021
10081022 // Setup
10091023 ctx := context .Background ()
@@ -1058,6 +1072,7 @@ func TestTaskService_ExecutePendingTasks(t *testing.T) {
10581072 t .Run ("Handles GetNextBatch error" , func (t * testing.T ) {
10591073 // Create TaskService
10601074 taskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
1075+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
10611076
10621077 // Setup
10631078 ctx := context .Background ()
@@ -1080,6 +1095,7 @@ func TestTaskService_ExecutePendingTasks(t *testing.T) {
10801095 t .Run ("Uses default maxTasks when 0 is provided" , func (t * testing.T ) {
10811096 // Create TaskService
10821097 taskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
1098+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
10831099
10841100 // Setup
10851101 ctx := context .Background ()
@@ -1115,6 +1131,7 @@ func TestTaskService_HandleBroadcastResumed(t *testing.T) {
11151131 mockLogger .EXPECT ().Error (gomock .Any ()).AnyTimes ()
11161132
11171133 taskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
1134+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
11181135
11191136 t .Run ("Successfully resumes a task for resumed broadcast" , func (t * testing.T ) {
11201137 // Setup
@@ -1264,6 +1281,7 @@ func TestTaskService_HandleBroadcastSent(t *testing.T) {
12641281 mockLogger .EXPECT ().Error (gomock .Any ()).AnyTimes ()
12651282
12661283 taskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
1284+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
12671285
12681286 t .Run ("Successfully completes a task for sent broadcast" , func (t * testing.T ) {
12691287 // Setup
@@ -1406,6 +1424,7 @@ func TestTaskService_HandleBroadcastFailed(t *testing.T) {
14061424 mockLogger .EXPECT ().Error (gomock .Any ()).AnyTimes ()
14071425
14081426 taskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
1427+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
14091428
14101429 t .Run ("Successfully marks task as failed for failed broadcast" , func (t * testing.T ) {
14111430 // Setup
@@ -1589,6 +1608,7 @@ func TestTaskService_HandleBroadcastCancelled(t *testing.T) {
15891608 mockLogger .EXPECT ().Error (gomock .Any ()).AnyTimes ()
15901609
15911610 taskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
1611+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
15921612
15931613 t .Run ("Successfully marks task as failed for cancelled broadcast" , func (t * testing.T ) {
15941614 // Setup
@@ -1732,6 +1752,7 @@ func TestTaskService_HandleBroadcastScheduledExtended(t *testing.T) {
17321752 mockLogger .EXPECT ().Error (gomock .Any ()).AnyTimes ()
17331753
17341754 taskService := NewTaskService (mockRepo , mockLogger , mockAuthService , apiEndpoint )
1755+ taskService .SetAutoExecuteImmediate (false ) // Disable for testing
17351756
17361757 t .Run ("Updates existing task when found for immediate sending" , func (t * testing.T ) {
17371758 // Setup
0 commit comments