@@ -2,7 +2,6 @@ package files_test
2
2
3
3
import (
4
4
"context"
5
- "sync"
6
5
"sync/atomic"
7
6
"testing"
8
7
"time"
@@ -35,7 +34,6 @@ func TestCancelledFetch(t *testing.T) {
35
34
t .Parallel ()
36
35
37
36
fileID := uuid .New ()
38
- rdy := make (chan struct {})
39
37
dbM := dbmock .NewMockStore (gomock .NewController (t ))
40
38
41
39
// First call should fail
@@ -56,33 +54,17 @@ func TestCancelledFetch(t *testing.T) {
56
54
ctx := dbauthz .AsFileReader (testutil .Context (t ,testutil .WaitShort ))
57
55
cache := files .New (prometheus .NewRegistry (),& coderdtest.FakeAuthorizer {})
58
56
59
- var wg sync.WaitGroup
60
-
61
57
// First call that will fail
62
- wg .Add (1 )
63
- go func () {
64
- _ ,err := cache .Acquire (ctx ,dbM ,fileID )
65
- close (rdy )
66
- assert .ErrorIs (t ,err ,context .Canceled )
67
- wg .Done ()
68
- }()
58
+ _ ,err := cache .Acquire (ctx ,dbM ,fileID )
59
+ assert .ErrorIs (t ,err ,context .Canceled )
69
60
70
61
// Second call, that should succeed
71
- wg .Add (1 )
72
- go func () {
73
- // Wait until the first goroutine has started
74
- <- rdy
75
- fs ,err := cache .Acquire (ctx ,dbM ,fileID )
76
- assert .NoError (t ,err )
77
- if fs != nil {
78
- fs .Close ()
79
- }
80
- wg .Done ()
81
- }()
82
-
83
- // We need that second Acquire call to be queued up
84
- time .Sleep (testutil .IntervalFast )
85
- wg .Wait ()
62
+ // Wait until the first goroutine has started
63
+ fs ,err := cache .Acquire (ctx ,dbM ,fileID )
64
+ assert .NoError (t ,err )
65
+ if fs != nil {
66
+ fs .Close ()
67
+ }
86
68
}
87
69
88
70
// nolint:paralleltest,tparallel // Serially testing is easier