@@ -14,7 +14,6 @@ import (
1414 "github.com/cschleiden/go-workflows/backend"
1515 "github.com/cschleiden/go-workflows/core"
1616 "github.com/cschleiden/go-workflows/workflow"
17- "github.com/stretchr/testify/assert"
1817 "github.com/stretchr/testify/mock"
1918 "github.com/stretchr/testify/require"
2019)
@@ -173,17 +172,17 @@ func TestNewWorker(t *testing.T) {
173172
174173 worker := NewWorker (mockBackend , mockTaskWorker , options )
175174
176- assert .NotNil (t , worker )
177- assert .Equal (t , mockTaskWorker , worker .tw )
178- assert .Equal (t , options , worker .options )
179- assert .NotNil (t , worker .taskQueue )
180- assert .NotNil (t , worker .logger )
181- assert .NotNil (t , worker .dispatcherDone )
175+ require .NotNil (t , worker )
176+ require .Equal (t , mockTaskWorker , worker .tw )
177+ require .Equal (t , options , worker .options )
178+ require .NotNil (t , worker .taskQueue )
179+ require .NotNil (t , worker .logger )
180+ require .NotNil (t , worker .dispatcherDone )
182181
183182 // Should add default queue if none provided
184- assert .Contains (t , worker .options .Queues , workflow .QueueDefault )
183+ require .Contains (t , worker .options .Queues , workflow .QueueDefault )
185184 // Should always include system queue
186- assert .Contains (t , worker .options .Queues , core .QueueSystem )
185+ require .Contains (t , worker .options .Queues , core .QueueSystem )
187186 })
188187
189188 t .Run ("with custom queues" , func (t * testing.T ) {
@@ -199,9 +198,9 @@ func TestNewWorker(t *testing.T) {
199198
200199 worker := NewWorker (mockBackend , mockTaskWorker , options )
201200
202- assert .Contains (t , worker .options .Queues , customQueue )
203- assert .Contains (t , worker .options .Queues , core .QueueSystem )
204- assert .Len (t , worker .options .Queues , 2 )
201+ require .Contains (t , worker .options .Queues , customQueue )
202+ require .Contains (t , worker .options .Queues , core .QueueSystem )
203+ require .Len (t , worker .options .Queues , 2 )
205204 })
206205
207206 t .Run ("system queue already included" , func (t * testing.T ) {
@@ -223,7 +222,7 @@ func TestNewWorker(t *testing.T) {
223222 queueCount ++
224223 }
225224 }
226- assert .Equal (t , 1 , queueCount )
225+ require .Equal (t , 1 , queueCount )
227226 })
228227}
229228
@@ -253,7 +252,7 @@ func TestWorker_Start(t *testing.T) {
253252 mockTaskWorker .On ("Get" , mock .Anything , mock .Anything ).Return (nil , nil )
254253
255254 err := worker .Start (ctx )
256- assert .NoError (t , err )
255+ require .NoError (t , err )
257256
258257 // Give pollers a moment to start
259258 time .Sleep (10 * time .Millisecond )
@@ -263,7 +262,7 @@ func TestWorker_Start(t *testing.T) {
263262
264263 // Wait for completion
265264 err = worker .WaitForCompletion ()
266- assert .NoError (t , err )
265+ require .NoError (t , err )
267266
268267 mockTaskWorker .AssertExpectations (t )
269268 })
@@ -285,9 +284,9 @@ func TestWorker_Start(t *testing.T) {
285284 mockTaskWorker .On ("Start" , ctx , mock .Anything ).Return (expectedErr )
286285
287286 err := worker .Start (ctx )
288- assert .Error (t , err )
289- assert .Contains (t , err .Error (), "starting task worker" )
290- assert .Contains (t , err .Error (), expectedErr .Error ())
287+ require .Error (t , err )
288+ require .Contains (t , err .Error (), "starting task worker" )
289+ require .Contains (t , err .Error (), expectedErr .Error ())
291290
292291 mockTaskWorker .AssertExpectations (t )
293292 })
@@ -311,8 +310,8 @@ func TestWorker_Poll(t *testing.T) {
311310 mockTaskWorker .On ("Get" , mock .Anything , mock .Anything ).Return (expectedTask , nil )
312311
313312 task , err := worker .poll (ctx , time .Second )
314- assert .NoError (t , err )
315- assert .Equal (t , expectedTask , task )
313+ require .NoError (t , err )
314+ require .Equal (t , expectedTask , task )
316315
317316 mockTaskWorker .AssertExpectations (t )
318317 })
@@ -333,8 +332,8 @@ func TestWorker_Poll(t *testing.T) {
333332 mockTaskWorker .On ("Get" , mock .Anything , mock .Anything ).Return (nil , context .DeadlineExceeded )
334333
335334 task , err := worker .poll (ctx , time .Millisecond )
336- assert .NoError (t , err )
337- assert .Nil (t , task )
335+ require .NoError (t , err )
336+ require .Nil (t , task )
338337
339338 mockTaskWorker .AssertExpectations (t )
340339 })
@@ -356,9 +355,9 @@ func TestWorker_Poll(t *testing.T) {
356355 mockTaskWorker .On ("Get" , mock .Anything , mock .Anything ).Return (nil , expectedErr )
357356
358357 task , err := worker .poll (ctx , time .Second )
359- assert .Error (t , err )
360- assert .Equal (t , expectedErr , err )
361- assert .Nil (t , task )
358+ require .Error (t , err )
359+ require .Equal (t , expectedErr , err )
360+ require .Nil (t , task )
362361
363362 mockTaskWorker .AssertExpectations (t )
364363 })
@@ -380,8 +379,8 @@ func TestWorker_Poll(t *testing.T) {
380379
381380 // Pass 0 timeout to test default timeout behavior
382381 task , err := worker .poll (ctx , 0 )
383- assert .NoError (t , err )
384- assert .Nil (t , task )
382+ require .NoError (t , err )
383+ require .Nil (t , task )
385384
386385 mockTaskWorker .AssertExpectations (t )
387386 })
@@ -408,7 +407,7 @@ func TestWorker_Handle(t *testing.T) {
408407 mockTaskWorker .On ("Complete" , mock .Anything , result , task ).Return (nil )
409408
410409 err := worker .handle (ctx , task )
411- assert .NoError (t , err )
410+ require .NoError (t , err )
412411
413412 mockTaskWorker .AssertExpectations (t )
414413 })
@@ -435,7 +434,7 @@ func TestWorker_Handle(t *testing.T) {
435434 mockTaskWorker .On ("Extend" , mock .Anything , task ).Return (nil ).Maybe ()
436435
437436 err := worker .handle (ctx , task )
438- assert .NoError (t , err )
437+ require .NoError (t , err )
439438
440439 mockTaskWorker .AssertExpectations (t )
441440 })
@@ -458,9 +457,9 @@ func TestWorker_Handle(t *testing.T) {
458457 mockTaskWorker .On ("Execute" , mock .Anything , task ).Return (nil , expectedErr )
459458
460459 err := worker .handle (ctx , task )
461- assert .Error (t , err )
462- assert .Contains (t , err .Error (), "executing task" )
463- assert .Contains (t , err .Error (), expectedErr .Error ())
460+ require .Error (t , err )
461+ require .Contains (t , err .Error (), "executing task" )
462+ require .Contains (t , err .Error (), expectedErr .Error ())
464463
465464 mockTaskWorker .AssertExpectations (t )
466465 })
@@ -485,8 +484,8 @@ func TestWorker_Handle(t *testing.T) {
485484 mockTaskWorker .On ("Complete" , mock .Anything , result , task ).Return (expectedErr )
486485
487486 err := worker .handle (ctx , task )
488- assert .Error (t , err )
489- assert .Equal (t , expectedErr , err )
487+ require .Error (t , err )
488+ require .Equal (t , expectedErr , err )
490489
491490 mockTaskWorker .AssertExpectations (t )
492491 })
@@ -601,7 +600,7 @@ func TestWorker_HeartbeatTask(t *testing.T) {
601600 worker .heartbeatTask (ctx , task , nil )
602601 duration := time .Since (start )
603602
604- assert .Less (t , duration , time .Millisecond * 100 )
603+ require .Less (t , duration , time .Millisecond * 100 )
605604
606605 // Should not have called Extend
607606 mockTaskWorker .AssertNotCalled (t , "Extend" )
@@ -629,8 +628,8 @@ func TestWorker_HeartbeatTask(t *testing.T) {
629628
630629 worker .heartbeatTask (ctx , task , nil )
631630
632- assert .False (t , testLogger .hasErrorLog ("could not heartbeat task" ))
633- assert .Equal (t , 0 , testLogger .errorLogCount ())
631+ require .False (t , testLogger .hasErrorLog ("could not heartbeat task" ))
632+ require .Equal (t , 0 , testLogger .errorLogCount ())
634633
635634 mockTaskWorker .AssertExpectations (t )
636635 })
@@ -657,8 +656,8 @@ func TestWorker_HeartbeatTask(t *testing.T) {
657656
658657 worker .heartbeatTask (ctx , task , nil )
659658
660- assert .False (t , testLogger .hasErrorLog ("could not heartbeat task" ))
661- assert .Equal (t , 0 , testLogger .errorLogCount ())
659+ require .False (t , testLogger .hasErrorLog ("could not heartbeat task" ))
660+ require .Equal (t , 0 , testLogger .errorLogCount ())
662661
663662 mockTaskWorker .AssertExpectations (t )
664663 })
@@ -688,8 +687,8 @@ func TestWorker_HeartbeatTask(t *testing.T) {
688687 worker .heartbeatTask (ctx , task , nil )
689688
690689 // Verify that other errors DO generate ERROR logs
691- assert .True (t , testLogger .hasErrorLog ("could not heartbeat task" ))
692- assert .Equal (t , 1 , testLogger .errorLogCount ())
690+ require .True (t , testLogger .hasErrorLog ("could not heartbeat task" ))
691+ require .Equal (t , 1 , testLogger .errorLogCount ())
693692
694693 mockTaskWorker .AssertExpectations (t )
695694 })
@@ -757,11 +756,11 @@ func TestWorker_FullWorkflow(t *testing.T) {
757756 // Cancel and wait for completion
758757 cancel ()
759758 err = worker .WaitForCompletion ()
760- assert .NoError (t , err )
759+ require .NoError (t , err )
761760
762761 // Verify results
763- assert .Equal (t , int32 (2 ), atomic .LoadInt32 (& processedTasks ))
764- assert .Len (t , taskResults , 2 )
762+ require .Equal (t , int32 (2 ), atomic .LoadInt32 (& processedTasks ))
763+ require .Len (t , taskResults , 2 )
765764
766765 mockTaskWorker .AssertExpectations (t )
767766 })
@@ -833,13 +832,13 @@ func TestWorker_FullWorkflow(t *testing.T) {
833832 // Cancel and wait for completion
834833 cancel ()
835834 err = worker .WaitForCompletion ()
836- assert .NoError (t , err )
835+ require .NoError (t , err )
837836
838837 // Verify concurrent execution
839- assert .GreaterOrEqual (t , int (atomic .LoadInt32 (& processedCount )), taskCount - 1 ) // Allow for timing issues
838+ require .GreaterOrEqual (t , int (atomic .LoadInt32 (& processedCount )), taskCount - 1 ) // Allow for timing issues
840839
841840 mu .Lock ()
842- assert .GreaterOrEqual (t , len (executionTimes ), taskCount - 1 ) // Allow for timing issues
841+ require .GreaterOrEqual (t , len (executionTimes ), taskCount - 1 ) // Allow for timing issues
843842 mu .Unlock ()
844843
845844 mockTaskWorker .AssertExpectations (t )
@@ -876,7 +875,7 @@ func TestWorker_ErrorHandling(t *testing.T) {
876875
877876 cancel ()
878877 err = worker .WaitForCompletion ()
879- assert .NoError (t , err )
878+ require .NoError (t , err )
880879
881880 mockTaskWorker .AssertExpectations (t )
882881 })
@@ -910,7 +909,7 @@ func TestWorker_ErrorHandling(t *testing.T) {
910909 cancel ()
911910
912911 err = worker .WaitForCompletion ()
913- assert .NoError (t , err )
912+ require .NoError (t , err )
914913
915914 // Don't assert specific expectations since timing can vary
916915 })
@@ -937,7 +936,7 @@ func TestWorker_Configuration(t *testing.T) {
937936 require .NoError (t , err )
938937
939938 err = worker .WaitForCompletion ()
940- assert .NoError (t , err )
939+ require .NoError (t , err )
941940
942941 // Should not call Get since no pollers
943942 mockTaskWorker .AssertNotCalled (t , "Get" )
@@ -956,12 +955,12 @@ func TestWorker_Configuration(t *testing.T) {
956955 worker := NewWorker (mockBackend , mockTaskWorker , options )
957956
958957 // The workQueue should be created with unlimited capacity
959- assert .NotNil (t , worker .taskQueue )
958+ require .NotNil (t , worker .taskQueue )
960959
961960 // Test that reservation works without blocking
962961 ctx := context .Background ()
963962 err := worker .taskQueue .reserve (ctx )
964- assert .NoError (t , err )
963+ require .NoError (t , err )
965964
966965 // Release should be no-op
967966 worker .taskQueue .release ()
@@ -993,7 +992,7 @@ func TestWorker_Configuration(t *testing.T) {
993992
994993 cancel ()
995994 err = worker .WaitForCompletion ()
996- assert .NoError (t , err )
995+ require .NoError (t , err )
997996
998997 mockTaskWorker .AssertExpectations (t )
999998 })
0 commit comments