Skip to content

Commit 7139de5

Browse files
committed
tapgarden: switch assertPendingBatchExists to wait.NoError
Replace the use of `require.Eventually` with `wait.NoError` in `assertPendingBatchExists`. This lets the helper return detailed error messages (nil batch, wrong number of seedlings, fetch failure) instead of a generic boolean failure.
1 parent e28ce8d commit 7139de5

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

tapgarden/planter_test.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,26 @@ func (t *mintingTestHarness) assertPendingBatchExists(numSeedlings int) {
336336

337337
// The planter is a state machine, so we need to wait until it has
338338
// reached the expected state.
339-
require.Eventually(t, func() bool {
339+
err := wait.NoError(func() error {
340340
batch, err := t.planter.PendingBatch()
341-
require.NoError(t, err)
341+
if err != nil {
342+
return fmt.Errorf("unable to fetch pending batch: %w",
343+
err)
344+
}
345+
346+
if batch == nil {
347+
return fmt.Errorf("expected pending batch to be " +
348+
"non-nil")
349+
}
342350

343-
require.NotNil(t, batch)
344-
return len(batch.Seedlings) == numSeedlings
345-
}, defaultTimeout, wait.PollInterval)
351+
if len(batch.Seedlings) < numSeedlings {
352+
return fmt.Errorf("expected %d seedlings, got %d",
353+
numSeedlings, len(batch.Seedlings))
354+
}
355+
356+
return nil
357+
}, defaultTimeout)
358+
require.NoError(t, err)
346359
}
347360

348361
// assertNoActiveBatch asserts that no pending batch exists.

0 commit comments

Comments
 (0)