-
Notifications
You must be signed in to change notification settings - Fork 24
test: assert output for collaborator list command #16
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #16 +/- ##
==========================================
- Coverage 62.81% 62.76% -0.05%
==========================================
Files 210 210
Lines 22053 22053
==========================================
- Hits 13852 13841 -11
- Misses 7121 7133 +12
+ Partials 1080 1079 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mwbrooks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments are the kind reviewers 🙇🏻
| app types.App | ||
| collaborators []types.SlackUser | ||
| expectedOutputs []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: We don't need to export these variables and the default is typically to not export unless it's intentional. Happy to hear your thoughts @zimeg so we can start to make this a standard across the tests. 🧠
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a super appreciated change - thank you for considering it! 🙏 ✨
I agree that we should aim to match test setups to this format also.
| expectedOutputs: []string{ | ||
| "0 collaborators", | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Assert 0 users are listed
praise: This assertion feels really good to have in place. Thanks for suggestion that we do this @zimeg 🙇🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mwbrooks Thanks so much! I'm glad we're finding meaningful cases to cover here 🧪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| expectedOutputs: []string{ | |
| "0 collaborators", | |
| }, | |
| expectedOutputs: []string{ | |
| " 0 collaborators", | |
| }, |
🤔 Nit: I forget how this is formatted in actual outputs, but adding this space might guard against "10 collaborators".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☝️ No blocker though since we're covering the meaningful cases already. That's just a wild edge perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with this suggestion 👍🏻 - matching \d0 collaborators doesn't seem too likely, but there's no harm in the space! Commit c0354de adds your suggestion with a comment explaining why we include a space, so future maintainers don't remove it.
| expectedOutputs: []string{ | ||
| "1 collaborator", | ||
| // User info: slackbot | ||
| "USLACKBOT", | ||
| "slackbot", | ||
| "[email protected]", | ||
| string(types.OWNER), | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Assert 1 user is listed
| expectedOutputs: []string{ | ||
| "2 collaborators", | ||
| // User info: slackbot | ||
| "USLACKBOT", | ||
| "slackbot", | ||
| "[email protected]", | ||
| string(types.OWNER), | ||
| // User info: bookworm | ||
| "U00READER", | ||
| "bookworm", | ||
| "[email protected]", | ||
| string(types.READER), | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Assert 2 users are listed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📚 🪱 🤖 ✨
What an interesting app!
| output := clientsMock.GetCombinedOutput() | ||
| for _, expectedOutput := range tt.expectedOutputs { | ||
| require.Contains(t, output, expectedOutput) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: This is the meat and potatoes that implements the assertions
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestListCommand(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: This files changes are identical to cmd/collaborators/collaborators_test.go
zimeg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Lot's of great tests, @mwbrooks 🫡
Thanks so much for following up on improvements to these tests. I'm so optimistic that this sets us up for later changes well. Please feel free to merge when the time is right.
| app types.App | ||
| collaborators []types.SlackUser | ||
| expectedOutputs []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a super appreciated change - thank you for considering it! 🙏 ✨
I agree that we should aim to match test setups to this format also.
| expectedOutputs: []string{ | ||
| "0 collaborators", | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mwbrooks Thanks so much! I'm glad we're finding meaningful cases to cover here 🧪
| expectedOutputs: []string{ | ||
| "0 collaborators", | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| expectedOutputs: []string{ | |
| "0 collaborators", | |
| }, | |
| expectedOutputs: []string{ | |
| " 0 collaborators", | |
| }, |
🤔 Nit: I forget how this is formatted in actual outputs, but adding this space might guard against "10 collaborators".
| expectedOutputs: []string{ | ||
| "0 collaborators", | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☝️ No blocker though since we're covering the meaningful cases already. That's just a wild edge perhaps?
| expectedOutputs: []string{ | ||
| "2 collaborators", | ||
| // User info: slackbot | ||
| "USLACKBOT", | ||
| "slackbot", | ||
| "[email protected]", | ||
| string(types.OWNER), | ||
| // User info: bookworm | ||
| "U00READER", | ||
| "bookworm", | ||
| "[email protected]", | ||
| string(types.READER), | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📚 🪱 🤖 ✨
What an interesting app!
|
Thanks for the quick review and originally suggesting this change @zimeg! 🚀 🚀 🚀 |
Summary
This pull request is a follow-up on PR #14 (comment) that adds tests to assert the stdout output for
collaboratorandcollaborator list.Requirements