diff --git a/server/assets/dev_test.go b/server/assets/dev_test.go index 3afc0fd..116029a 100644 --- a/server/assets/dev_test.go +++ b/server/assets/dev_test.go @@ -9,6 +9,7 @@ import ( ) func TestDevStaticDev(t *testing.T) { + t.Parallel() conf := testfunc.NewConfig() conf.DevMode = true ts := testfunc.RunningServer(t, conf) @@ -29,6 +30,7 @@ func TestDevStaticDev(t *testing.T) { } func TestDevStaticProd(t *testing.T) { + t.Parallel() ts := testfunc.RunningServer(t, testfunc.NewConfig()) defer ts.Cleanup() diff --git a/server/security/csp_test.go b/server/security/csp_test.go index 60cdc8f..c81843c 100644 --- a/server/security/csp_test.go +++ b/server/security/csp_test.go @@ -25,6 +25,7 @@ var cspRegexp = regexp.MustCompile( ) func TestCSP(t *testing.T) { + t.Parallel() conf := testfunc.NewConfig() conf.ObjectURLPattern = &url.URL{Scheme: "https", Host: "fancy-cdn.com", Path: ":path:"} ts := testfunc.RunningServer(t, conf) diff --git a/server/storage/dev_test.go b/server/storage/dev_test.go index 12de36b..4c0ca89 100644 --- a/server/storage/dev_test.go +++ b/server/storage/dev_test.go @@ -36,6 +36,7 @@ func TestDevStorageDev(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() tmp := t.TempDir() objectRoot := filepath.Join(tmp, "object") @@ -93,6 +94,7 @@ func TestDevStorageProd(t *testing.T) { } for name, url := range urls { t.Run(name, func(t *testing.T) { + t.Parallel() ts := testfunc.RunningServer(t, testfunc.NewConfig()) defer ts.Cleanup() diff --git a/server/uploads/uploads_test.go b/server/uploads/uploads_test.go index 396f6d8..bcb201c 100644 --- a/server/uploads/uploads_test.go +++ b/server/uploads/uploads_test.go @@ -131,6 +131,7 @@ func TestSanitizeUploadName(t *testing.T) { } func TestUploadObjects(t *testing.T) { + t.Parallel() logger := testfunc.NewMemoryLogger() storageBackend := testfunc.NewMemoryStorageBackend() diff --git a/server/views/healthz_test.go b/server/views/healthz_test.go index 17ac311..4470bd5 100644 --- a/server/views/healthz_test.go +++ b/server/views/healthz_test.go @@ -10,6 +10,7 @@ import ( ) func TestHealthz(t *testing.T) { + t.Parallel() ts := testfunc.RunningServer(t, testfunc.NewConfig()) defer ts.Cleanup() diff --git a/server/views/index_test.go b/server/views/index_test.go index f60f202..87c818b 100644 --- a/server/views/index_test.go +++ b/server/views/index_test.go @@ -11,6 +11,7 @@ import ( ) func TestIndex(t *testing.T) { + t.Parallel() ts := testfunc.RunningServer(t, testfunc.NewConfig()) defer ts.Cleanup() diff --git a/server/views/upload_history_test.go b/server/views/upload_history_test.go index eff4200..7313449 100644 --- a/server/views/upload_history_test.go +++ b/server/views/upload_history_test.go @@ -11,6 +11,7 @@ import ( ) func TestUploadHistory(t *testing.T) { + t.Parallel() ts := testfunc.RunningServer(t, testfunc.NewConfig()) defer ts.Cleanup() diff --git a/server/views/upload_test.go b/server/views/upload_test.go index 4f4fcaf..c81ac6a 100644 --- a/server/views/upload_test.go +++ b/server/views/upload_test.go @@ -36,6 +36,7 @@ func addFile(t *testing.T, writer *multipart.Writer, filename, content string) { } func TestUpload(t *testing.T) { + t.Parallel() ts := testfunc.RunningServer(t, testfunc.NewConfig()) defer ts.Cleanup() @@ -70,6 +71,7 @@ func TestUpload(t *testing.T) { } func TestUploadJSON(t *testing.T) { + t.Parallel() ts := testfunc.RunningServer(t, testfunc.NewConfig()) defer ts.Cleanup() @@ -120,6 +122,7 @@ func TestUploadJSON(t *testing.T) { } func TestUploadNoMultipart(t *testing.T) { + t.Parallel() ts := testfunc.RunningServer(t, testfunc.NewConfig()) defer ts.Cleanup() @@ -135,6 +138,7 @@ func TestUploadNoMultipart(t *testing.T) { } func TestUploadTooLarge(t *testing.T) { + t.Parallel() conf := testfunc.NewConfig() conf.MaxUploadBytes = 1 ts := testfunc.RunningServer(t, conf) diff --git a/testfunc/integration.go b/testfunc/integration.go index d8a9cc3..9a25e23 100644 --- a/testfunc/integration.go +++ b/testfunc/integration.go @@ -48,6 +48,7 @@ type TestServer struct { } func RunningServer(t *testing.T, config *config.Config) TestServer { + t.Helper() ctx, cancel := context.WithCancel(context.Background()) t.Cleanup(cancel) port, done, err := run(t, ctx, config) diff --git a/testfunc/storage.go b/testfunc/storage.go index c4b8608..21de8ac 100644 --- a/testfunc/storage.go +++ b/testfunc/storage.go @@ -55,9 +55,12 @@ type StoredS3Object struct { type FakeS3Client struct { Objects map[string]StoredS3Object + mu sync.Mutex } func (f *FakeS3Client) PutObject(ctx context.Context, params *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error) { + f.mu.Lock() + defer f.mu.Unlock() var buf bytes.Buffer if _, err := io.Copy(&buf, params.Body); err != nil { return nil, fmt.Errorf("copying object: %w", err)