Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2637f55

Browse files
authored
chore: de-flake TestWorkspaceAgent_Metadata (coder#7036)
1 parent c68ab7d commit 2637f55

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

coderd/workspaceagents_test.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -1353,9 +1353,13 @@ func TestWorkspaceAgent_Metadata(t *testing.T) {
13531353
var update []codersdk.WorkspaceAgentMetadata
13541354

13551355
check := func(want codersdk.WorkspaceAgentMetadataResult, got codersdk.WorkspaceAgentMetadata) {
1356-
require.WithinDuration(t, want.CollectedAt, got.Result.CollectedAt, time.Second)
1356+
require.Greater(t, got.Result.CollectedAt, want.CollectedAt)
1357+
1358+
ageImpliedNow := got.Result.CollectedAt.Add(time.Duration(got.Result.Age) * time.Second)
1359+
// We use a long WithinDuration to tolerate slow CI, but we're still making sure
1360+
// that Age is within the ballpark.
13571361
require.WithinDuration(
1358-
t, time.Now(), got.Result.CollectedAt.Add(time.Duration(got.Result.Age)*time.Second), time.Second,
1362+
t, time.Now(), ageImpliedNow, time.Second*10,
13591363
)
13601364
require.Equal(t, want.Value, got.Result.Value)
13611365
require.Equal(t, want.Error, got.Result.Error)

0 commit comments

Comments
 (0)