Skip to content

Commit e94fdaf

Browse files
committed
Avoid data race on buffer by reading after exit
1 parent 3cd7460 commit e94fdaf

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

cli/server_test.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ func TestServer(t *testing.T) {
8080
go func() {
8181
err := root.ExecuteContext(ctx)
8282
require.ErrorIs(t, err, context.Canceled)
83+
84+
// Verify that credentials were output to the terminal.
85+
wantEmail := "email: admin@coder.com"
86+
wantPassword := "password: password"
87+
assert.Contains(t, stdoutBuf.String(), wantEmail, "expected output %q; got no match", wantEmail)
88+
assert.Contains(t, stdoutBuf.String(), wantPassword, "expected output %q; got no match", wantPassword)
8389
}()
8490
var token string
8591
require.Eventually(t, func() bool {
@@ -92,11 +98,6 @@ func TestServer(t *testing.T) {
9298
require.NoError(t, err)
9399
parsed, err := url.Parse(accessURL)
94100
require.NoError(t, err)
95-
// Verify that credentials were output to the terminal.
96-
wantEmail := "email: admin@coder.com"
97-
wantPassword := "password: password"
98-
assert.Contains(t, stdoutBuf.String(), wantEmail, "expected output %q; got no match", wantEmail)
99-
assert.Contains(t, stdoutBuf.String(), wantPassword, "expected output %q; got no match", wantPassword)
100101
client := codersdk.New(parsed)
101102
client.SessionToken = token
102103
_, err = client.User(ctx, codersdk.Me)

0 commit comments

Comments
 (0)