- Notifications
You must be signed in to change notification settings - Fork928
feat: Output username and password forcode server --dev
#1193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package cli_test | ||
import ( | ||
"bytes" | ||
"context" | ||
"crypto/ecdsa" | ||
"crypto/elliptic" | ||
@@ -18,6 +19,7 @@ import ( | ||
"testing" | ||
"time" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"go.uber.org/goleak" | ||
@@ -73,9 +75,17 @@ func TestServer(t *testing.T) { | ||
ctx, cancelFunc := context.WithCancel(context.Background()) | ||
defer cancelFunc() | ||
root, cfg := clitest.New(t, "server", "--dev", "--skip-tunnel", "--address", ":0") | ||
var stdoutBuf bytes.Buffer | ||
root.SetOutput(&stdoutBuf) | ||
Comment on lines +78 to +79 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. small nit: if you're only ever calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Good point, I didn't consider There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Nope! Not important at all, just thought I'd mention. | ||
go func() { | ||
err := root.ExecuteContext(ctx) | ||
require.ErrorIs(t, err, context.Canceled) | ||
// Verify that credentials were output to the terminal. | ||
wantEmail := "email: admin@coder.com" | ||
wantPassword := "password: password" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Maybe we could export There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. That's definitely an option, wediscussed it a bit and I added a commit that this this but ultimately dropped it before the merge. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Oops, I should've read back before I commented! | ||
assert.Contains(t, stdoutBuf.String(), wantEmail, "expected output %q; got no match", wantEmail) | ||
assert.Contains(t, stdoutBuf.String(), wantPassword, "expected output %q; got no match", wantPassword) | ||
}() | ||
var token string | ||
require.Eventually(t, func() bool { | ||