Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaab0335

Browse files
committed
at this point the calls are just serialized anyway
1 parentdb89836 commitaab0335

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

‎coderd/files/cache_test.go

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package files_test
22

33
import (
44
"context"
5-
"sync"
65
"sync/atomic"
76
"testing"
87
"time"
@@ -35,7 +34,6 @@ func TestCancelledFetch(t *testing.T) {
3534
t.Parallel()
3635

3736
fileID:=uuid.New()
38-
rdy:=make(chanstruct{})
3937
dbM:=dbmock.NewMockStore(gomock.NewController(t))
4038

4139
// First call should fail
@@ -56,33 +54,17 @@ func TestCancelledFetch(t *testing.T) {
5654
ctx:=dbauthz.AsFileReader(testutil.Context(t,testutil.WaitShort))
5755
cache:=files.New(prometheus.NewRegistry(),&coderdtest.FakeAuthorizer{})
5856

59-
varwg sync.WaitGroup
60-
6157
// First call that will fail
62-
wg.Add(1)
63-
gofunc() {
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)
6960

7061
// Second call, that should succeed
71-
wg.Add(1)
72-
gofunc() {
73-
// Wait until the first goroutine has started
74-
<-rdy
75-
fs,err:=cache.Acquire(ctx,dbM,fileID)
76-
assert.NoError(t,err)
77-
iffs!=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+
iffs!=nil {
66+
fs.Close()
67+
}
8668
}
8769

8870
// nolint:paralleltest,tparallel // Serially testing is easier

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp