From fb87759aa7adaf500292094531cfdf97edcdb18e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Thu, 10 Mar 2022 21:48:13 +0100 Subject: [PATCH] cloudapi/test: properly end depsolving goroutine when cancel is called MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the goroutine was never stopped because it was all the time calling RequestJob that returned a TimeoutError. Signed-off-by: Ondřej Budai --- internal/cloudapi/v2/v2_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/cloudapi/v2/v2_test.go b/internal/cloudapi/v2/v2_test.go index d6a154f82..c780499af 100644 --- a/internal/cloudapi/v2/v2_test.go +++ b/internal/cloudapi/v2/v2_test.go @@ -45,7 +45,12 @@ func newV2Server(t *testing.T, dir string, depsolveChannels []string, enableJWT depsolveContext, cancel := context.WithCancel(context.Background()) go func() { for { - _, token, _, _, _, err := workerServer.RequestJob(context.Background(), test_distro.TestDistroName, []string{"depsolve"}, depsolveChannels) + _, token, _, _, _, err := workerServer.RequestJob(depsolveContext, test_distro.TestDistroName, []string{"depsolve"}, depsolveChannels) + select { + case <-depsolveContext.Done(): + return + default: + } if err != nil { continue }