Skip to content

Commit

Permalink
fix test introduced in rebase that didnt' clean up Context and thus c…
Browse files Browse the repository at this point in the history
…ased race
  • Loading branch information
jasonmills committed Dec 7, 2022
1 parent 3c39cf2 commit 29097e2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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))
})
}

Expand Down

0 comments on commit 29097e2

Please sign in to comment.