Accessing an app should update the workspace's LastUsedAt. NOTE: Despite our efforts with the flush channel, this is inherently racy when used with parallel tests on the same workspace/app. This function accepts a timeout duration instead of a context so that it always gets a fresh deadline. Caller
(t testing.TB, details *Details, timeout time.Duration)
| 2463 | // proxying to a fake unreachable app), which can leave too little time |
| 2464 | // for the Eventually loop below and cause flakes. |
| 2465 | func assertWorkspaceLastUsedAtUpdated(t testing.TB, details *Details, timeout time.Duration) { |
| 2466 | t.Helper() |
| 2467 | |
| 2468 | ctx := testutil.Context(t, timeout) |
| 2469 | |
| 2470 | require.NotNil(t, details.Workspace, "can't assert LastUsedAt on a nil workspace!") |
| 2471 | before, err := details.SDKClient.Workspace(ctx, details.Workspace.ID) |
| 2472 | require.NoError(t, err) |
| 2473 | testutil.Eventually(ctx, t, func(ctx context.Context) bool { |
| 2474 | // We may need to flush multiple times, since the stats from the app we are testing might be |
| 2475 | // collected asynchronously from when we see the connection close, and thus, could race |
| 2476 | // against being flushed. |
| 2477 | details.FlushStats() |
| 2478 | after, err := details.SDKClient.Workspace(ctx, details.Workspace.ID) |
| 2479 | return assert.NoError(t, err) && after.LastUsedAt.After(before.LastUsedAt) |
| 2480 | }, testutil.IntervalMedium) |
| 2481 | } |
| 2482 | |
| 2483 | // Except when it sometimes shouldn't (e.g. no access) |
| 2484 | // NOTE: Despite our efforts with the flush channel, this is inherently racy when used with |
no test coverage detected