From e1dcb8e1f4d83dbb17c0303fe1fef30139aefda7 Mon Sep 17 00:00:00 2001 From: jmills Date: Wed, 7 Dec 2022 21:44:55 +0000 Subject: [PATCH] fix test introduced in rebase that didnt' clean up Context and thus cased race --- app_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app_test.go b/app_test.go index 7beae0157..667294c79 100644 --- a/app_test.go +++ b/app_test.go @@ -1285,6 +1285,9 @@ func TestAppStart(t *testing.T) { t.Run("StartTwiceWithHooksErrors", func(t *testing.T) { t.Parallel() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + app := fxtest.New(t, Invoke(func(lc Lifecycle) { lc.Append(Hook{ @@ -1293,13 +1296,13 @@ func TestAppStart(t *testing.T) { }) }), ) - assert.NoError(t, app.Start(context.Background())) - err := app.Start(context.Background()) + assert.NoError(t, app.Start(ctx)) + err := app.Start(ctx) if assert.Error(t, err) { assert.ErrorContains(t, err, "attempted to start lifecycle when in state: started") } - app.Stop(context.Background()) - assert.NoError(t, app.Start(context.Background())) + app.Stop(ctx) + assert.NoError(t, app.Start(ctx)) }) }