Skip to content

feat: added whomai cmd to coder cli #13814

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 9, 2024
Merged

Conversation

BRAVO68WEB
Copy link
Contributor

Example Usage:-
image

@cdr-bot cdr-bot bot added the community Pull Requests and issues created by the community. label Jul 8, 2024
@BRAVO68WEB
Copy link
Contributor Author

Added Requested changes @Emyrk

@Emyrk
Copy link
Member

Emyrk commented Jul 8, 2024

@BRAVO68WEB happy to include this.

Can you add a test for both when this works and when the user is logged out?

You will also need to run a make gen to generate the docs associated with the cli.

I can assist in any of these comments 👍

@BRAVO68WEB
Copy link
Contributor Author

Yeah about the tests, I found writing test for this project hard

@Emyrk
Copy link
Member

Emyrk commented Jul 8, 2024

For testing the failure condition, you can copy this:

coder/cli/login_test.go

Lines 26 to 33 in 44cb400

t.Run("InitialUserNoTTY", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
root, _ := clitest.New(t, "login", client.URL.String())
err := root.Run()
require.Error(t, err)
})

For the successful case, this one has the setup you would need:

t.Run("OK", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
_ = coderdtest.CreateFirstUser(t, client)
inv, root := clitest.New(t, "publickey")
clitest.SetupConfig(t, client, root)
buf := new(bytes.Buffer)
inv.Stdout = buf
err := inv.Run()
require.NoError(t, err)
publicKey := buf.String()
require.NotEmpty(t, publicKey)
})

Essentially just a test to verify an error when not logged in, and no error when the user is.

@BRAVO68WEB BRAVO68WEB requested a review from Emyrk July 9, 2024 06:07
@Emyrk
Copy link
Member

Emyrk commented Jul 9, 2024

Ah, you have to run make update-golden-files -B as well. (I add -B to be sure).
@BRAVO68WEB

Copy link
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will approve and merge when CI passes

@BRAVO68WEB
Copy link
Contributor Author

Ah, you have to run make update-golden-files -B as well. (I add -B to be sure). @BRAVO68WEB

Done 👍🏻

@BRAVO68WEB BRAVO68WEB requested a review from Emyrk July 9, 2024 16:06
@BRAVO68WEB
Copy link
Contributor Author

BTW I got this, is it expected ?
image

@Emyrk
Copy link
Member

Emyrk commented Jul 9, 2024

BTW I got this, is it expected ? image

That can happen based on some helm state. It is something we should improve in our makefile.

Regardless, it looks like you got the right files generated 👍. I approved CI, let's see what it looks like.

@BRAVO68WEB
Copy link
Contributor Author

CI Passed 😄

@Emyrk Emyrk merged commit b07e306 into coder:main Jul 9, 2024
28 checks passed
@Emyrk
Copy link
Member

Emyrk commented Jul 9, 2024

@BRAVO68WEB merged! Thanks for the contribution!

@github-actions github-actions bot locked and limited conversation to collaborators Jul 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community Pull Requests and issues created by the community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants