defer ctxCancel

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
This commit is contained in:
Tiger Kaovilai
2023-04-16 13:22:48 -04:00
parent 84daa36efe
commit 3f4b258dee
8 changed files with 24 additions and 10 deletions

View File

@@ -738,7 +738,9 @@ func TestWaitExecHandleHooks(t *testing.T) {
ctx := context.Background()
if test.sharedHooksContextTimeout > 0 {
ctx, _ = context.WithTimeout(ctx, test.sharedHooksContextTimeout)
var ctxCancel context.CancelFunc
ctx, ctxCancel = context.WithTimeout(ctx, test.sharedHooksContextTimeout)
defer ctxCancel()
}
errs := h.HandleHooks(ctx, velerotest.NewLogger(), test.initialPod, test.byContainer)