@@ -41,6 +41,11 @@ import (
4141 "go.uber.org/zap/zaptest"
4242)
4343
44+ func batchWithState (batch entity.Batch , state entity.BatchState ) entity.Batch {
45+ batch .State = state
46+ return batch
47+ }
48+
4449// requestIDPayload serializes a RequestID to JSON bytes for test message payloads.
4550func requestIDPayload (t * testing.T , id string ) []byte {
4651 payload , err := entity.RequestID {ID : id }.ToBytes ()
@@ -86,7 +91,7 @@ func newTestController(t *testing.T, ctrl *gomock.Controller, cnt *countermock.M
8691 mockBatchStore := storagemock .NewMockBatchStore (ctrl )
8792 mockBatchStore .EXPECT ().GetByQueueAndStates (gomock .Any (), gomock .Any (), gomock .Any ()).Return (nil , nil ).AnyTimes ()
8893 mockBatchStore .EXPECT ().Create (gomock .Any (), gomock .Any ()).Return (nil ).AnyTimes ()
89- mockBatchStore .EXPECT ().UpdateState (gomock .Any (), gomock .Any (), int32 (1 ), int32 (2 ), entity . BatchStateCreated ).Return (nil ).AnyTimes ()
94+ mockBatchStore .EXPECT ().Update (gomock .Any (), gomock .Any (), int32 (1 ), int32 (2 )).Return (nil ).AnyTimes ()
9095
9196 mockReqStore := storagemock .NewMockRequestStore (ctrl )
9297 req := testRequest ()
@@ -173,7 +178,14 @@ func TestController_Process_PublishesBatchedLog(t *testing.T) {
173178 mockBatchStore := storagemock .NewMockBatchStore (ctrl )
174179 mockBatchStore .EXPECT ().GetByQueueAndStates (gomock .Any (), gomock .Any (), gomock .Any ()).Return (nil , nil ).AnyTimes ()
175180 mockBatchStore .EXPECT ().Create (gomock .Any (), gomock .Any ()).Return (nil )
176- mockBatchStore .EXPECT ().UpdateState (gomock .Any (), "test-queue/batch/1" , int32 (1 ), int32 (2 ), entity .BatchStateCreated ).Return (nil )
181+ mockBatchStore .EXPECT ().Update (gomock .Any (), entity.Batch {
182+ ID : "test-queue/batch/1" ,
183+ Queue : request .Queue ,
184+ Contains : []string {request .ID },
185+ Dependencies : []string {},
186+ State : entity .BatchStateCreated ,
187+ Version : 1 ,
188+ }, int32 (1 ), int32 (2 )).Return (nil )
177189
178190 mockReqStore := storagemock .NewMockRequestStore (ctrl )
179191 mockReqStore .EXPECT ().Get (gomock .Any (), request .ID ).Return (request , nil )
@@ -349,7 +361,14 @@ func TestController_Process_WithDependencies(t *testing.T) {
349361 mockBatchStore := storagemock .NewMockBatchStore (ctrl )
350362 mockBatchStore .EXPECT ().GetByQueueAndStates (gomock .Any (), "test-queue" , gomock .Any ()).Return (activeBatches , nil )
351363 mockBatchStore .EXPECT ().Create (gomock .Any (), gomock .Any ()).Return (nil )
352- mockBatchStore .EXPECT ().UpdateState (gomock .Any (), "test-queue/batch/1" , int32 (1 ), int32 (2 ), entity .BatchStateCreated ).Return (nil )
364+ mockBatchStore .EXPECT ().Update (gomock .Any (), entity.Batch {
365+ ID : "test-queue/batch/1" ,
366+ Queue : request .Queue ,
367+ Contains : []string {request .ID },
368+ Dependencies : []string {"test-queue/batch/1" , "test-queue/batch/2" },
369+ State : entity .BatchStateCreated ,
370+ Version : 1 ,
371+ }, int32 (1 ), int32 (2 )).Return (nil )
353372
354373 mockBatchDependentStore := storagemock .NewMockBatchDependentStore (ctrl )
355374 // batch/1 has no existing dependents.
@@ -418,7 +437,14 @@ func TestController_Process_AnalyzerSelectsSubset(t *testing.T) {
418437 mockBatchStore := storagemock .NewMockBatchStore (ctrl )
419438 mockBatchStore .EXPECT ().GetByQueueAndStates (gomock .Any (), "test-queue" , gomock .Any ()).Return (activeBatches , nil )
420439 mockBatchStore .EXPECT ().Create (gomock .Any (), gomock .Any ()).Return (nil )
421- mockBatchStore .EXPECT ().UpdateState (gomock .Any (), "test-queue/batch/1" , int32 (1 ), int32 (2 ), entity .BatchStateCreated ).Return (nil )
440+ mockBatchStore .EXPECT ().Update (gomock .Any (), entity.Batch {
441+ ID : "test-queue/batch/1" ,
442+ Queue : request .Queue ,
443+ Contains : []string {request .ID },
444+ Dependencies : []string {"test-queue/batch/2" },
445+ State : entity .BatchStateCreated ,
446+ Version : 1 ,
447+ }, int32 (1 ), int32 (2 )).Return (nil )
422448
423449 mockBatchDependentStore := storagemock .NewMockBatchDependentStore (ctrl )
424450 // Only batch/2 is selected by the analyzer, so only it gets a reverse-index update.
@@ -712,7 +738,14 @@ func TestController_Process_RecoveryAfterPriorCAS(t *testing.T) {
712738 mockBatchStore := storagemock .NewMockBatchStore (ctrl )
713739 mockBatchStore .EXPECT ().GetByQueueAndStates (gomock .Any (), "test-queue" , gomock .Any ()).Return (nil , nil )
714740 mockBatchStore .EXPECT ().Create (gomock .Any (), gomock .Any ()).Return (nil )
715- mockBatchStore .EXPECT ().UpdateState (gomock .Any (), "test-queue/batch/1" , int32 (1 ), int32 (2 ), entity .BatchStateCreated ).Return (nil )
741+ mockBatchStore .EXPECT ().Update (gomock .Any (), entity.Batch {
742+ ID : "test-queue/batch/1" ,
743+ Queue : request .Queue ,
744+ Contains : []string {request .ID },
745+ Dependencies : []string {},
746+ State : entity .BatchStateCreated ,
747+ Version : 1 ,
748+ }, int32 (1 ), int32 (2 )).Return (nil )
716749
717750 mockBatchDependentStore := storagemock .NewMockBatchDependentStore (ctrl )
718751 mockBatchDependentStore .EXPECT ().Create (gomock .Any (), gomock .Any ()).Return (nil )
@@ -784,7 +817,7 @@ func TestController_Process_ReadiesBatchBeforePublishing(t *testing.T) {
784817 Dependents : []string {},
785818 Version : 1 ,
786819 }).Return (nil ),
787- batchStore .EXPECT ().UpdateState (gomock .Any (), batch . ID , int32 (1 ), int32 (2 ), entity . BatchStateCreated ).Return (nil ),
820+ batchStore .EXPECT ().Update (gomock .Any (), batchWithState ( batch , entity . BatchStateCreated ) , int32 (1 ), int32 (2 )).Return (nil ),
788821 publisher .EXPECT ().Publish (gomock .Any (), "log" , gomock .Any ()).Return (nil ),
789822 publisher .EXPECT ().Publish (gomock .Any (), "speculate" , gomock .Any ()).Return (nil ),
790823 )
@@ -846,8 +879,22 @@ func TestController_Process_RedeliveryMintsFreshBatchID(t *testing.T) {
846879 return nil
847880 },
848881 ).Times (2 )
849- batchStore .EXPECT ().UpdateState (gomock .Any (), "test-queue/batch/1" , int32 (1 ), int32 (2 ), entity .BatchStateCreated ).Return (nil )
850- batchStore .EXPECT ().UpdateState (gomock .Any (), "test-queue/batch/2" , int32 (1 ), int32 (2 ), entity .BatchStateCreated ).Return (nil )
882+ batchStore .EXPECT ().Update (gomock .Any (), entity.Batch {
883+ ID : "test-queue/batch/1" ,
884+ Queue : firstRequest .Queue ,
885+ Contains : []string {firstRequest .ID },
886+ Dependencies : []string {},
887+ State : entity .BatchStateCreated ,
888+ Version : 1 ,
889+ }, int32 (1 ), int32 (2 )).Return (nil )
890+ batchStore .EXPECT ().Update (gomock .Any (), entity.Batch {
891+ ID : "test-queue/batch/2" ,
892+ Queue : firstRequest .Queue ,
893+ Contains : []string {firstRequest .ID },
894+ Dependencies : []string {},
895+ State : entity .BatchStateCreated ,
896+ Version : 1 ,
897+ }, int32 (1 ), int32 (2 )).Return (nil )
851898
852899 batchDependentStore := storagemock .NewMockBatchDependentStore (ctrl )
853900 batchDependentStore .EXPECT ().Create (gomock .Any (), gomock .Any ()).Return (nil ).Times (2 )
@@ -978,7 +1025,7 @@ func TestController_PopulateBatch_Errors(t *testing.T) {
9781025 Dependents : []string {"test-queue/batch/old" , batch .ID },
9791026 Version : 2 ,
9801027 }, int32 (2 ), int32 (3 )).Return (nil )
981- batchStore .EXPECT ().UpdateState (gomock .Any (), batch . ID , int32 (1 ), int32 (2 ), entity . BatchStateCreated ).Return (storeErr )
1028+ batchStore .EXPECT ().Update (gomock .Any (), batchWithState ( batch , entity . BatchStateCreated ) , int32 (1 ), int32 (2 )).Return (storeErr )
9821029 },
9831030 errMsg : "failed to mark batch" ,
9841031 },
0 commit comments