Skip to content

Commit f4950c1

Browse files
committed
Fallback to dktest.DefaultCleanupTimeout if the dktest.Options doesn't have one specified
1 parent b1d02e2 commit f4950c1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

dktesting/dktesting.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ func (s *ContainerSpec) Cleanup() (retErr error) {
3030
retErr = fmt.Errorf("error closing Docker client: %w", err)
3131
}
3232
}()
33-
ctx, timeoutCancelFunc := context.WithTimeout(context.Background(), s.Options.CleanupTimeout)
33+
cleanupTimeout := s.Options.CleanupTimeout
34+
if cleanupTimeout <= 0 {
35+
cleanupTimeout = dktest.DefaultCleanupTimeout
36+
}
37+
ctx, timeoutCancelFunc := context.WithTimeout(context.Background(), cleanupTimeout)
3438
defer timeoutCancelFunc()
3539
if _, err := dc.ImageRemove(ctx, s.ImageName, types.ImageRemoveOptions{Force: true, PruneChildren: true}); err != nil {
3640
return err

0 commit comments

Comments
 (0)