Skip to content

Commit 1bf8924

Browse files
committed
remove legacy test case
1 parent 96299f0 commit 1bf8924

File tree

5 files changed

+13
-45
lines changed

5 files changed

+13
-45
lines changed

coderd/apikey/apikey_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func TestGenerate(t *testing.T) {
128128

129129
// Assert that the hashed secret is correct.
130130
hashed := sha256.Sum256([]byte(keytokens[1]))
131-
assert.ElementsMatch(t, hashed, key.HashedSecret[:])
131+
assert.ElementsMatch(t, hashed, key.HashedSecret)
132132

133133
assert.Equal(t, tc.params.UserID, key.UserID)
134134
assert.WithinDuration(t, dbtime.Now(), key.CreatedAt, time.Second*5)

coderd/database/dbauthz/setup_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func (s *MethodTestSuite) NotAuthorizedErrorTest(ctx context.Context, az *coderd
264264
// any case where the error is nil and the response is an empty slice.
265265
if err != nil || !hasEmptySliceResponse(resp) {
266266
s.Errorf(err, "method should an error with cancellation")
267-
s.ErrorIsf(err, context.Canceled, "error should match context.Cancelled")
267+
s.ErrorIsf(err, context.Canceled, "error should match context.Canceled")
268268
}
269269
})
270270
}

coderd/workspaceagents_test.go

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -939,32 +939,6 @@ func TestWorkspaceAgentReportStats(t *testing.T) {
939939
agentClient.SetSessionToken(r.AgentToken)
940940

941941
_, err := agentClient.PostStats(context.Background(), &agentsdk.Stats{
942-
ConnectionsByProto: map[string]int64{"TCP": 1},
943-
// Set connection count to 1 but all session counts to zero to
944-
// assert we aren't updating last_used_at for a connections that may
945-
// be spawned passively by the dashboard.
946-
ConnectionCount: 1,
947-
RxPackets: 1,
948-
RxBytes: 1,
949-
TxPackets: 1,
950-
TxBytes: 1,
951-
SessionCountVSCode: 0,
952-
SessionCountJetBrains: 0,
953-
SessionCountReconnectingPTY: 0,
954-
SessionCountSSH: 0,
955-
ConnectionMedianLatencyMS: 10,
956-
})
957-
require.NoError(t, err)
958-
959-
newWorkspace, err := client.Workspace(context.Background(), r.Workspace.ID)
960-
require.NoError(t, err)
961-
962-
assert.True(t,
963-
newWorkspace.LastUsedAt.Equal(r.Workspace.LastUsedAt),
964-
"%s and %s should not differ", newWorkspace.LastUsedAt, r.Workspace.LastUsedAt,
965-
)
966-
967-
_, err = agentClient.PostStats(context.Background(), &agentsdk.Stats{
968942
ConnectionsByProto: map[string]int64{"TCP": 1},
969943
ConnectionCount: 1,
970944
RxPackets: 1,
@@ -979,7 +953,7 @@ func TestWorkspaceAgentReportStats(t *testing.T) {
979953
})
980954
require.NoError(t, err)
981955

982-
newWorkspace, err = client.Workspace(context.Background(), r.Workspace.ID)
956+
newWorkspace, err := client.Workspace(context.Background(), r.Workspace.ID)
983957
require.NoError(t, err)
984958

985959
assert.True(t,

coderd/workspaceapps/proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ func (s *Server) proxyWorkspaceApp(rw http.ResponseWriter, r *http.Request, appT
573573
}
574574

575575
// This strips the session token from a workspace app request.
576-
cookieHeaders := r.Header.Values("Cookie")[:]
576+
cookieHeaders := r.Header.Values("Cookie")
577577
r.Header.Del("Cookie")
578578
for _, cookieHeader := range cookieHeaders {
579579
r.Header.Add("Cookie", httpapi.StripCoderCookies(cookieHeader))

coderd/workspacestats/reporter.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,16 @@ func (r *Reporter) ReportAgentStats(ctx context.Context, now time.Time, workspac
153153
}
154154
return nil
155155
})
156-
if sessionCount(stats) > 0 {
157-
errGroup.Go(func() error {
158-
err := r.opts.Database.UpdateWorkspaceLastUsedAt(ctx, database.UpdateWorkspaceLastUsedAtParams{
159-
ID: workspace.ID,
160-
LastUsedAt: now,
161-
})
162-
if err != nil {
163-
return xerrors.Errorf("update workspace LastUsedAt: %w", err)
164-
}
165-
return nil
156+
errGroup.Go(func() error {
157+
err := r.opts.Database.UpdateWorkspaceLastUsedAt(ctx, database.UpdateWorkspaceLastUsedAtParams{
158+
ID: workspace.ID,
159+
LastUsedAt: now,
166160
})
167-
}
161+
if err != nil {
162+
return xerrors.Errorf("update workspace LastUsedAt: %w", err)
163+
}
164+
return nil
165+
})
168166
if r.opts.UpdateAgentMetricsFn != nil {
169167
errGroup.Go(func() error {
170168
user, err := r.opts.Database.GetUserByID(ctx, workspace.OwnerID)
@@ -194,7 +192,3 @@ func (r *Reporter) ReportAgentStats(ctx context.Context, now time.Time, workspac
194192

195193
return nil
196194
}
197-
198-
func sessionCount(s *agentproto.Stats) int64 {
199-
return s.SessionCountVscode + s.SessionCountJetbrains + s.SessionCountReconnectingPty + s.SessionCountSsh
200-
}

0 commit comments

Comments
 (0)