Skip to content

Commit 93f9337

Browse files
committed
Add some more t.Parallel and t.Helper
1 parent 2fac3c3 commit 93f9337

File tree

10 files changed

+17
-0
lines changed

10 files changed

+17
-0
lines changed

server/assets/dev_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
)
1010

1111
func TestDevStaticDev(t *testing.T) {
12+
t.Parallel()
1213
conf := testfunc.NewConfig()
1314
conf.DevMode = true
1415
ts := testfunc.RunningServer(t, conf)
@@ -29,6 +30,7 @@ func TestDevStaticDev(t *testing.T) {
2930
}
3031

3132
func TestDevStaticProd(t *testing.T) {
33+
t.Parallel()
3234
ts := testfunc.RunningServer(t, testfunc.NewConfig())
3335
defer ts.Cleanup()
3436

server/security/csp_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var cspRegexp = regexp.MustCompile(
2525
)
2626

2727
func TestCSP(t *testing.T) {
28+
t.Parallel()
2829
conf := testfunc.NewConfig()
2930
conf.ObjectURLPattern = &url.URL{Scheme: "https", Host: "fancy-cdn.com", Path: ":path:"}
3031
ts := testfunc.RunningServer(t, conf)

server/storage/dev_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func TestDevStorageDev(t *testing.T) {
3636
}
3737
for _, tt := range tests {
3838
t.Run(tt.name, func(t *testing.T) {
39+
t.Parallel()
3940
tmp := t.TempDir()
4041

4142
objectRoot := filepath.Join(tmp, "object")
@@ -93,6 +94,7 @@ func TestDevStorageProd(t *testing.T) {
9394
}
9495
for name, url := range urls {
9596
t.Run(name, func(t *testing.T) {
97+
t.Parallel()
9698
ts := testfunc.RunningServer(t, testfunc.NewConfig())
9799
defer ts.Cleanup()
98100

server/uploads/uploads_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ func TestSanitizeUploadName(t *testing.T) {
131131
}
132132

133133
func TestUploadObjects(t *testing.T) {
134+
t.Parallel()
134135
logger := testfunc.NewMemoryLogger()
135136
storageBackend := testfunc.NewMemoryStorageBackend()
136137

server/views/healthz_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
)
1111

1212
func TestHealthz(t *testing.T) {
13+
t.Parallel()
1314
ts := testfunc.RunningServer(t, testfunc.NewConfig())
1415
defer ts.Cleanup()
1516

server/views/index_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
)
1212

1313
func TestIndex(t *testing.T) {
14+
t.Parallel()
1415
ts := testfunc.RunningServer(t, testfunc.NewConfig())
1516
defer ts.Cleanup()
1617

server/views/upload_history_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
)
1212

1313
func TestUploadHistory(t *testing.T) {
14+
t.Parallel()
1415
ts := testfunc.RunningServer(t, testfunc.NewConfig())
1516
defer ts.Cleanup()
1617

server/views/upload_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func addFile(t *testing.T, writer *multipart.Writer, filename, content string) {
3636
}
3737

3838
func TestUpload(t *testing.T) {
39+
t.Parallel()
3940
ts := testfunc.RunningServer(t, testfunc.NewConfig())
4041
defer ts.Cleanup()
4142

@@ -70,6 +71,7 @@ func TestUpload(t *testing.T) {
7071
}
7172

7273
func TestUploadJSON(t *testing.T) {
74+
t.Parallel()
7375
ts := testfunc.RunningServer(t, testfunc.NewConfig())
7476
defer ts.Cleanup()
7577

@@ -120,6 +122,7 @@ func TestUploadJSON(t *testing.T) {
120122
}
121123

122124
func TestUploadNoMultipart(t *testing.T) {
125+
t.Parallel()
123126
ts := testfunc.RunningServer(t, testfunc.NewConfig())
124127
defer ts.Cleanup()
125128

@@ -135,6 +138,7 @@ func TestUploadNoMultipart(t *testing.T) {
135138
}
136139

137140
func TestUploadTooLarge(t *testing.T) {
141+
t.Parallel()
138142
conf := testfunc.NewConfig()
139143
conf.MaxUploadBytes = 1
140144
ts := testfunc.RunningServer(t, conf)

testfunc/integration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type TestServer struct {
4848
}
4949

5050
func RunningServer(t *testing.T, config *config.Config) TestServer {
51+
t.Helper()
5152
ctx, cancel := context.WithCancel(context.Background())
5253
t.Cleanup(cancel)
5354
port, done, err := run(t, ctx, config)

testfunc/storage.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ type StoredS3Object struct {
5555

5656
type FakeS3Client struct {
5757
Objects map[string]StoredS3Object
58+
mu sync.Mutex
5859
}
5960

6061
func (f *FakeS3Client) PutObject(ctx context.Context, params *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error) {
62+
f.mu.Lock()
63+
defer f.mu.Unlock()
6164
var buf bytes.Buffer
6265
if _, err := io.Copy(&buf, params.Body); err != nil {
6366
return nil, fmt.Errorf("copying object: %w", err)

0 commit comments

Comments
 (0)