MCPcopy Index your code
hub / github.com/coder/coder / TestWatcher_LostAccess

Function TestWatcher_LostAccess

coderd/workspaceconnwatcher/watcher_test.go:258–288  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

256}
257
258func TestWatcher_LostAccess(t *testing.T) {
259 t.Parallel()
260 ctx := testutil.Context(t, testutil.WaitShort)
261 logger := testutil.Logger(t)
262 h := newHarness(ctx, t, logger)
263
264 h.db.EXPECT().GetLatestWorkspaceBuildWithStatusByWorkspaceID(gomock.Any(), h.workspace.ID).
265 Times(1).
266 Return(database.GetLatestWorkspaceBuildWithStatusByWorkspaceIDRow{
267 Transition: database.WorkspaceTransitionStart,
268 BuildNumber: 1,
269 JobStatus: database.ProvisionerJobStatusSucceeded,
270 WorkspaceTable: database.WorkspaceTable{
271 ID: h.workspace.ID,
272 OwnerID: uuid.UUID{99}, // workspace gets a new owner, e.g.
273 OrganizationID: orgID,
274 },
275 }, nil)
276
277 dec, err := h.Dial(ctx, "wss://local.test/")
278 require.NoError(t, err)
279 defer func() {
280 _ = dec.Close()
281 }()
282 events := dec.Chan()
283 e0 := testutil.RequireReceive(ctx, t, events)
284 require.NotNil(t, e0.Error)
285 require.Equal(t, workspacesdk.WatchErrorDatabase, e0.Error.Code)
286 require.False(t, e0.Error.Retryable)
287 require.Equal(t, "unauthorized", e0.Error.Details, "should not leak internal auth details")
288}
289
290func TestWatcher_PublishChanges(t *testing.T) {
291 t.Parallel()

Callers

nothing calls this directly

Calls 10

ContextFunction · 0.92
LoggerFunction · 0.92
RequireReceiveFunction · 0.92
newHarnessFunction · 0.85
DialMethod · 0.65
CloseMethod · 0.65
EXPECTMethod · 0.45
ChanMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected