Skip to content

Commit 8573ba7

Browse files
committed
address PR comments
1 parent b714d69 commit 8573ba7

File tree

5 files changed

+15
-21
lines changed

5 files changed

+15
-21
lines changed

coderd/database/dbmem/dbmem.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -985,9 +985,6 @@ func (q *FakeQuerier) BatchUpdateWorkspaceLastUsedAt(_ context.Context, arg data
985985
q.workspaces[i].LastUsedAt = arg.LastUsedAt
986986
n++
987987
}
988-
if n == 0 {
989-
return sql.ErrNoRows
990-
}
991988
return nil
992989
}
993990

coderd/workspaceapps/apptest/apptest.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,10 +1570,9 @@ func testReconnectingPTY(ctx context.Context, t *testing.T, client *codersdk.Cli
15701570
func assertWorkspaceLastUsedAtUpdated(t testing.TB, details *Details) {
15711571
t.Helper()
15721572

1573-
<-time.After(testutil.IntervalMedium) // Wait for Bicopy to finish.
1574-
details.FlushStats()
15751573
// Wait for stats to fully flush.
15761574
require.Eventually(t, func() bool {
1575+
details.FlushStats()
15771576
ws, err := details.SDKClient.Workspace(context.Background(), details.Workspace.ID)
15781577
assert.NoError(t, err)
15791578
return ws.LastUsedAt.After(details.Workspace.LastUsedAt)
@@ -1585,9 +1584,7 @@ func assertWorkspaceLastUsedAtUpdated(t testing.TB, details *Details) {
15851584
func assertWorkspaceLastUsedAtNotUpdated(t testing.TB, details *Details) {
15861585
t.Helper()
15871586

1588-
<-time.After(testutil.IntervalMedium) // Wait for Bicopy to finish.
15891587
details.FlushStats()
1590-
<-time.After(testutil.IntervalMedium) // Wait for stats to fully flush.
15911588
ws, err := details.SDKClient.Workspace(context.Background(), details.Workspace.ID)
15921589
require.NoError(t, err)
15931590
require.Equal(t, ws.LastUsedAt, details.Workspace.LastUsedAt, "workspace LastUsedAt updated when it should not have been")

coderd/workspaceapps_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,12 @@ func TestWorkspaceApps(t *testing.T) {
262262
opts.AppHost = ""
263263
}
264264

265-
statsFlushCh := make(chan chan<- struct{})
266-
opts.StatsCollectorOptions.Flush = statsFlushCh
265+
flushStatsCollectorCh := make(chan chan<- struct{}, 1)
266+
opts.StatsCollectorOptions.Flush = flushStatsCollectorCh
267267
flushStats := func() {
268-
flushDone := make(chan struct{})
269-
statsFlushCh <- flushDone
270-
<-flushDone
268+
flushStatsCollectorDone := make(chan struct{}, 1)
269+
flushStatsCollectorCh <- flushStatsCollectorDone
270+
<-flushStatsCollectorDone
271271
}
272272
client := coderdtest.New(t, &coderdtest.Options{
273273
DeploymentValues: deploymentValues,

enterprise/coderd/coderdenttest/proxytest.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ type ProxyOptions struct {
3838
// ProxyURL is optional
3939
ProxyURL *url.URL
4040

41-
// Flush is optional
42-
Flush chan chan<- struct{}
41+
// FlushStats is optional
42+
FlushStats chan chan<- struct{}
4343
}
4444

4545
// NewWorkspaceProxy will configure a wsproxy.Server with the given options.
@@ -116,8 +116,8 @@ func NewWorkspaceProxy(t *testing.T, coderdAPI *coderd.API, owner *codersdk.Clie
116116
// Inherit collector options from coderd, but keep the wsproxy reporter.
117117
statsCollectorOptions := coderdAPI.Options.WorkspaceAppsStatsCollectorOptions
118118
statsCollectorOptions.Reporter = nil
119-
if options.Flush != nil {
120-
statsCollectorOptions.Flush = options.Flush
119+
if options.FlushStats != nil {
120+
statsCollectorOptions.Flush = options.FlushStats
121121
}
122122

123123
wssrv, err := wsproxy.New(ctx, &wsproxy.Options{

enterprise/wsproxy/wsproxy_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,11 @@ func TestWorkspaceProxyWorkspaceApps(t *testing.T) {
442442
"*",
443443
}
444444

445-
proxyFlushCh := make(chan chan<- struct{})
445+
proxyStatsCollectorFlushCh := make(chan chan<- struct{}, 1)
446446
flushStats := func() {
447-
proxyFlushDone := make(chan struct{})
448-
proxyFlushCh <- proxyFlushDone
449-
<-proxyFlushDone
447+
proxyStatsCollectorFlushDone := make(chan struct{}, 1)
448+
proxyStatsCollectorFlushCh <- proxyStatsCollectorFlushDone
449+
<-proxyStatsCollectorFlushDone
450450
}
451451

452452
client, closer, api, user := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
@@ -483,7 +483,7 @@ func TestWorkspaceProxyWorkspaceApps(t *testing.T) {
483483
Name: "best-proxy",
484484
AppHostname: opts.AppHost,
485485
DisablePathApps: opts.DisablePathApps,
486-
Flush: proxyFlushCh,
486+
FlushStats: proxyStatsCollectorFlushCh,
487487
})
488488

489489
return &apptest.Deployment{

0 commit comments

Comments
 (0)