From f69a2dd03e7ef7491fa7e770186a8c5ff78c77c6 Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Sat, 1 Jun 2024 13:41:56 -0500 Subject: [PATCH] Fix race condition in TestInstallRelease_Wait_Interrupted test Signed-off-by: Alex Johnson --- pkg/action/install_test.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index 69b9cbc48..694595120 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -429,16 +429,14 @@ func TestInstallRelease_Wait_Interrupted(t *testing.T) { instAction.Wait = true vals := map[string]interface{}{} - ctx := context.Background() - ctx, cancel := context.WithCancel(ctx) + ctx, cancel := context.WithCancel(context.Background()) time.AfterFunc(time.Second, cancel) goroutines := runtime.NumGoroutine() - res, err := instAction.RunWithContext(ctx, buildChart(), vals) + _, err := instAction.RunWithContext(ctx, buildChart(), vals) is.Error(err) - is.Contains(res.Info.Description, "Release \"interrupted-release\" failed: context canceled") - is.Equal(res.Info.Status, release.StatusFailed) + is.Contains(err.Error(), "context canceled") is.Equal(goroutines+1, runtime.NumGoroutine()) // installation goroutine still is in background time.Sleep(10 * time.Second) // wait for goroutine to finish @@ -515,8 +513,7 @@ func TestInstallRelease_Atomic_Interrupted(t *testing.T) { instAction.Atomic = true vals := map[string]interface{}{} - ctx := context.Background() - ctx, cancel := context.WithCancel(ctx) + ctx, cancel := context.WithCancel(context.Background()) time.AfterFunc(time.Second, cancel) res, err := instAction.RunWithContext(ctx, buildChart(), vals)