Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7d9d161

Browse files
committed
testutil.Eventually
1 parent5a74d6f commit7d9d161

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

‎agent/agent_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,19 +2178,21 @@ func TestAgent_DevcontainerRecreate(t *testing.T) {
21782178
o.ExperimentalDevcontainersEnabled=true
21792179
})
21802180

2181+
ctx:=testutil.Context(t,testutil.WaitLong)
2182+
21812183
// We enabled autostart for the devcontainer, so ready is a good
21822184
// indication that the devcontainer is up and running. Importantly,
21832185
// this also means that the devcontainer startup is no longer
21842186
// producing logs that may interfere with the recreate logs.
2185-
require.Eventually(t,func()bool {
2187+
testutil.Eventually(ctx,t,func(context.Context)bool {
21862188
states:=client.GetLifecycleStates()
21872189
returnslices.Contains(states,codersdk.WorkspaceAgentLifecycleReady)
2188-
},testutil.WaitLong,testutil.IntervalMedium,"devcontainer not ready")
2190+
},testutil.IntervalMedium,"devcontainer not ready")
21892191

21902192
t.Logf("Looking for container with label: devcontainer.local_folder=%s",workspaceFolder)
21912193

21922194
varcontainer docker.APIContainers
2193-
require.Eventually(t,func()bool {
2195+
testutil.Eventually(ctx,t,func(context.Context)bool {
21942196
containers,err:=pool.Client.ListContainers(docker.ListContainersOptions{All:true})
21952197
iferr!=nil {
21962198
t.Logf("Error listing containers: %v",err)
@@ -2205,7 +2207,7 @@ func TestAgent_DevcontainerRecreate(t *testing.T) {
22052207
}
22062208
}
22072209
returnfalse
2208-
},testutil.WaitLong,testutil.IntervalMedium,"no container with workspace folder label found")
2210+
},testutil.IntervalMedium,"no container with workspace folder label found")
22092211
deferfunc(container docker.APIContainers) {
22102212
// We can't rely on pool here because the container is not
22112213
// managed by it (it is managed by @devcontainer/cli).
@@ -2217,7 +2219,7 @@ func TestAgent_DevcontainerRecreate(t *testing.T) {
22172219
assert.Error(t,err,"container should be removed by recreate")
22182220
}(container)
22192221

2220-
ctx:=testutil.Context(t,testutil.WaitLong)
2222+
ctx=testutil.Context(t,testutil.WaitLong)// Reset context.
22212223

22222224
// Capture logs via ScriptLogger.
22232225
logsCh:=make(chan*proto.BatchCreateLogsRequest,1)
@@ -2253,7 +2255,7 @@ waitForOutcomeLoop:
22532255
t.Logf("Checking there's a new container with label: devcontainer.local_folder=%s",workspaceFolder)
22542256

22552257
// Make sure the container exists and isn't the same as the old one.
2256-
require.Eventually(t,func()bool {
2258+
testutil.Eventually(ctx,t,func(context.Context)bool {
22572259
containers,err:=pool.Client.ListContainers(docker.ListContainersOptions{All:true})
22582260
iferr!=nil {
22592261
t.Logf("Error listing containers: %v",err)
@@ -2272,7 +2274,7 @@ waitForOutcomeLoop:
22722274
}
22732275
}
22742276
returnfalse
2275-
},testutil.WaitLong,testutil.IntervalMedium,"new devcontainer not found")
2277+
},testutil.IntervalMedium,"new devcontainer not found")
22762278
deferfunc(container docker.APIContainers) {
22772279
// We can't rely on pool here because the container is not
22782280
// managed by it (it is managed by @devcontainer/cli).

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp