cloudapi/test: properly end depsolving goroutine when cancel is called

Previously, the goroutine was never stopped because it was all the time
calling RequestJob that returned a TimeoutError.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2022-03-10 21:48:13 +01:00 committed by Ondřej Budai
parent 00ea3eb285
commit fb87759aa7

View file

@ -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
}