Skip to content

Commit d3ecb18

Browse files
committed
require.Eventually
1 parent ac8d4b2 commit d3ecb18

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

integration/integration_test.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,15 @@ func setup(ctx context.Context, t *testing.T) string {
187187
)
188188

189189
// Wait for container to come up
190-
waitLoop:
191-
for {
192-
select {
193-
case <-ctx.Done():
194-
t.Fatalf("coder failed to become ready in time")
195-
default:
196-
_, rc := execContainer(ctx, t, ctr.ID, fmt.Sprintf(`curl -s --fail %s/api/v2/buildinfo`, localURL))
197-
if rc == 0 {
198-
break waitLoop
199-
}
200-
t.Logf("not ready yet...")
201-
<-time.After(time.Second)
190+
require.Eventually(t, func() bool {
191+
_, rc := execContainer(ctx, t, ctr.ID, fmt.Sprintf(`curl -s --fail %s/api/v2/buildinfo`, localURL))
192+
if rc == 0 {
193+
return true
202194
}
203-
}
195+
t.Logf("not ready yet...")
196+
return false
197+
}, 10*time.Second, time.Second, "coder failed to become ready in time")
198+
204199
// Perform first time setup
205200
_, rc := execContainer(ctx, t, ctr.ID, fmt.Sprintf(`coder login %s --first-user-email=%q --first-user-password=%q --first-user-trial=false --first-user-username=%q`, localURL, testEmail, testPassword, testUsername))
206201
require.Equal(t, 0, rc, "failed to perform first-time setup")

0 commit comments

Comments
 (0)