integration: Don't env cleanup before parallel subtests

Calling function returned from setupTest (which calls testEnv.Clean) in
a defer block inside a test that spawns parallel subtests caused the
cleanup function to be called before any of the subtest did anything.

Change the defer expressions to use `t.Cleanup` instead to call it only
after all subtests have also finished.
This only changes tests which have parallel subtests.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit f9e2eed55d)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2023-07-13 15:06:36 +02:00
parent 71f749be8d
commit 959889efd9
11 changed files with 19 additions and 19 deletions

View File

@@ -32,7 +32,7 @@ import (
// TestPluginInvalidJSON tests that POST endpoints that expect a body return
// the correct error when sending invalid JSON requests.
func TestPluginInvalidJSON(t *testing.T) {
defer setupTest(t)()
t.Cleanup(setupTest(t))
// POST endpoints that accept / expect a JSON body;
endpoints := []string{