Skip to content

Commit 32cdf0d

Browse files
committed
test: Wait for WorkspaceResources to complete before exiting (#1149)
This caused a flake seen in: https://github.com/coder/coder/runs/6162655678?check_suite_focus=true#step:9:87
1 parent e53710c commit 32cdf0d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cli/cliui/resources_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func TestWorkspaceResources(t *testing.T) {
1717
t.Run("SingleAgentSSH", func(t *testing.T) {
1818
t.Parallel()
1919
ptty := ptytest.New(t)
20+
done := make(chan struct{})
2021
go func() {
2122
err := cliui.WorkspaceResources(ptty.Output(), []codersdk.WorkspaceResource{{
2223
Type: "google_compute_instance",
@@ -32,14 +33,17 @@ func TestWorkspaceResources(t *testing.T) {
3233
WorkspaceName: "example",
3334
})
3435
require.NoError(t, err)
36+
close(done)
3537
}()
3638
ptty.ExpectMatch("coder ssh example")
39+
<-done
3740
})
3841

3942
t.Run("MultipleStates", func(t *testing.T) {
4043
t.Parallel()
4144
ptty := ptytest.New(t)
4245
disconnected := database.Now().Add(-4 * time.Second)
46+
done := make(chan struct{})
4347
go func() {
4448
err := cliui.WorkspaceResources(ptty.Output(), []codersdk.WorkspaceResource{{
4549
Transition: database.WorkspaceTransitionStart,
@@ -82,9 +86,11 @@ func TestWorkspaceResources(t *testing.T) {
8286
HideAccess: false,
8387
})
8488
require.NoError(t, err)
89+
close(done)
8590
}()
8691
ptty.ExpectMatch("google_compute_disk.root")
8792
ptty.ExpectMatch("google_compute_instance.dev")
8893
ptty.ExpectMatch("coder ssh dev.postgres")
94+
<-done
8995
})
9096
}

0 commit comments

Comments
 (0)