Skip to content

Commit 57926bb

Browse files
committed
Check for successful provisioner connection in test
1 parent a56220a commit 57926bb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

cli/provisionerrun_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/coder/coder/cli/clitest"
88
"github.com/coder/coder/coderd/coderdtest"
99
"github.com/coder/coder/codersdk"
10+
"github.com/coder/coder/pty/ptytest"
1011
"github.com/stretchr/testify/require"
1112
)
1213

@@ -34,7 +35,12 @@ func TestProvisionerRun(t *testing.T) {
3435
ctx, cancelFunc := context.WithCancel(context.Background())
3536
defer cancelFunc()
3637

37-
cmd, root := clitest.New(t, "provisioners", "run", "--token", token.String())
38+
cmd, root := clitest.New(t, "provisioners", "run",
39+
"--token", token.String(),
40+
"--verbose", // to test debug-level logs
41+
)
42+
pty := ptytest.New(t)
43+
cmd.SetErr(pty.Output())
3844
// command should only have access to provisioner auth token, not user credentials
3945
err = root.URL().Write(client.URL.String())
4046
require.NoError(t, err)
@@ -43,5 +49,7 @@ func TestProvisionerRun(t *testing.T) {
4349
defer close(doneCh)
4450
doneCh <- cmd.ExecuteContext(ctx)
4551
}()
52+
53+
pty.ExpectMatch("\tprovisioner client connected")
4654
})
4755
}

provisionerd/provisionerd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (p *Server) connect(ctx context.Context) {
108108
continue
109109
}
110110
p.clientValue.Store(client)
111-
p.opts.Logger.Debug(context.Background(), "connected")
111+
p.opts.Logger.Debug(context.Background(), "provisioner client connected")
112112
break
113113
}
114114
select {

0 commit comments

Comments
 (0)