From 49776274e72db5f9dd3bab1ca1e524e75d936667 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 23 Feb 2024 09:20:33 -0800 Subject: [PATCH] Close the parent context in serve_test when complete --- pkg/cmd/serve_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/serve_test.go b/pkg/cmd/serve_test.go index 6a5b137e0f..287e691dde 100644 --- a/pkg/cmd/serve_test.go +++ b/pkg/cmd/serve_test.go @@ -1,6 +1,7 @@ package cmd import ( + "context" "os" "path/filepath" "strings" @@ -30,10 +31,10 @@ func RunServeTest(t *testing.T, args []string, assertConfig func(t *testing.T, m cmd.SetArgs(args) cmd.RunE = func(cmd *cobra.Command, args []string) error { - _, err := config.Complete(cmd.Context()) - t.Cleanup(func() { - // TODO: RunnableServer.closeFunc should be called on Cleanup, but it is private. - }) + ctx, cancel := context.WithCancel(cmd.Context()) + t.Cleanup(cancel) + + _, err := config.Complete(ctx) if err != nil { return err }