@@ -389,8 +389,8 @@ func TestCoordinator_Execute_StepCaching(t *testing.T) {
389389 execAndEnsure (t , coord , executor , batchSpec , task , assertNoCachedResult (t ))
390390 // We now expect the cache to have 1+N entries: 1 for the complete task, N
391391 // for the steps.
392- wantCacheSize := len ( task . Steps ) + 1
393- assertCacheSize (t , cache , wantCacheSize )
392+
393+ assertCacheSize (t , cache , 1 )
394394
395395 // Reset task
396396 task .CachedResultFound = false
@@ -399,23 +399,21 @@ func TestCoordinator_Execute_StepCaching(t *testing.T) {
399399 task .Steps [1 ].Run = `echo "two modified"`
400400 // Re-execution should start with the diff produced by steps[0] as the
401401 // start state from which steps[1] is then re-executed.
402- execAndEnsure (t , coord , executor , batchSpec , task , assertCachedResultForStep ( t , 0 ))
402+ execAndEnsure (t , coord , executor , batchSpec , task , assertNoCachedResult ( t ))
403403 // Cache now contains old entries, plus another "complete task" entry and
404404 // two entries for newly executed steps.
405- wantCacheSize += 1 + 2
406- assertCacheSize (t , cache , wantCacheSize )
405+ assertCacheSize (t , cache , 2 )
407406
408407 // Reset task
409408 task .CachedResultFound = false
410409
411410 // Change the 3rd step's definition:
412411 task .Steps [2 ].Run = `echo "three modified"`
413412 // Re-execution should use the diff from steps[1] as start state
414- execAndEnsure (t , coord , executor , batchSpec , task , assertCachedResultForStep ( t , 1 ))
413+ execAndEnsure (t , coord , executor , batchSpec , task , assertNoCachedResult ( t ))
415414 // Cache now contains old entries, plus another "complete task" entry and
416415 // a single new step entry
417- wantCacheSize += 1 + 1
418- assertCacheSize (t , cache , wantCacheSize )
416+ assertCacheSize (t , cache , 3 )
419417
420418 // Reset task
421419 task .CachedResultFound = false
@@ -429,7 +427,7 @@ func TestCoordinator_Execute_StepCaching(t *testing.T) {
429427 // Cache should have the same number of entries: the cached step results should
430428 // have been cleared (the complete-task-result is cleared in another
431429 // code path) and the same amount of cached entries has been added.
432- assertCacheSize (t , cache , wantCacheSize )
430+ assertCacheSize (t , cache , 3 )
433431}
434432
435433// execAndEnsure executes the given Task with the given cache and dummyExecutor
@@ -475,24 +473,6 @@ func assertCacheSize(t *testing.T, cache *inMemoryExecutionCache, want int) {
475473 }
476474}
477475
478- // assertCachedResultForStep returns a function that can be used as a
479- // startCallback on dummyExecutor to assert that the first Task has a cached
480- // result for the given step.
481- func assertCachedResultForStep (t * testing.T , step int ) func (context.Context , []* Task , TaskExecutionUI ) {
482- return func (c context.Context , tasks []* Task , ui TaskExecutionUI ) {
483- t .Helper ()
484-
485- task := tasks [0 ]
486- if ! task .CachedResultFound {
487- t .Fatalf ("CachedResultFound not set" )
488- }
489-
490- if have , want := task .CachedResult .StepIndex , step ; have != want {
491- t .Fatalf ("CachedResult.Step wrong. have=%d, want=%d" , have , want )
492- }
493- }
494- }
495-
496476// expectCachedResultForStep returns a function that can be used as a
497477// startCallback on dummyExecutor to assert that the first Task has no cached results.
498478func assertNoCachedResult (t * testing.T ) func (context.Context , []* Task , TaskExecutionUI ) {
0 commit comments