From 7c8529b914cfecb29a5c1be4810c55f34c317851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 1 Apr 2019 17:26:11 +0100 Subject: [PATCH] give up on refactoring TestFileUpload The reason that t.Parallel broke the tests was because the parent test must finish before the parallel subtests can start. So, we'd be closing the httptest server and removing the tmpfile before any of the parallel subtests even began. We could refactor this to make the subtests parallel, but they're only two, and the parent is already parallel, so it's not worth the effort. See the added comment. --- query_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/query_test.go b/query_test.go index 97952ac..500bf4e 100644 --- a/query_test.go +++ b/query_test.go @@ -984,12 +984,13 @@ func TestFileUpload(t *testing.T) { {SetUploadFiles(`input[name="upload"]`, []string{tmpfile.Name()}, NodeVisible)}, } + // Don't run these tests in parallel. The only way to do so would be to + // fire a separate httptest server and tmpfile for each. There's no way + // to share these resources easily among parallel subtests, as the + // parent must finish for the children to run, made impossible by the + // defers above. for i, test := range tests { t.Run(fmt.Sprintf("test %d", i), func(t *testing.T) { - // TODO: refactor the test so the subtests can run in - // parallel - //t.Parallel() - ctx, cancel := testAllocate(t, "") defer cancel()