Skip to content

Conversation

@mwbrooks
Copy link
Member

@mwbrooks mwbrooks commented Apr 7, 2025

Summary

This pull request is a follow-up on PR #14 (comment) that adds tests to assert the stdout output for collaborator and collaborator list.

Requirements

@mwbrooks mwbrooks added code health M-T: Test improvements and anything that improves code health semver:patch Use on pull requests to describe the release version increment labels Apr 7, 2025
@mwbrooks mwbrooks added this to the Next Release milestone Apr 7, 2025
@mwbrooks mwbrooks self-assigned this Apr 7, 2025
@codecov
Copy link

codecov bot commented Apr 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.76%. Comparing base (3c995d5) to head (d4d4bd4).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member Author

@mwbrooks mwbrooks left a 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 🙇🏻

Comment on lines +32 to +34
app types.App
collaborators []types.SlackUser
expectedOutputs []string
Copy link
Member Author

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. 🧠

Copy link
Member

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.

Comment on lines 41 to 43
expectedOutputs: []string{
"0 collaborators",
},
Copy link
Member Author

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 🙇🏻

Copy link
Member

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 🧪

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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".

Copy link
Member

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?

Copy link
Member Author

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.

Comment on lines +57 to +64
expectedOutputs: []string{
"1 collaborator",
// User info: slackbot
"USLACKBOT",
"slackbot",
"[email protected]",
string(types.OWNER),
},
Copy link
Member Author

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

Comment on lines +84 to +96
expectedOutputs: []string{
"2 collaborators",
// User info: slackbot
"USLACKBOT",
"slackbot",
"[email protected]",
string(types.OWNER),
// User info: bookworm
"U00READER",
"bookworm",
"[email protected]",
string(types.READER),
},
Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

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

📚 🪱 🤖 ✨

What an interesting app!

Comment on lines +128 to +131
output := clientsMock.GetCombinedOutput()
for _, expectedOutput := range tt.expectedOutputs {
require.Contains(t, output, expectedOutput)
}
Copy link
Member Author

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) {
Copy link
Member Author

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

@mwbrooks mwbrooks marked this pull request as ready for review April 7, 2025 16:51
@mwbrooks mwbrooks requested a review from a team as a code owner April 7, 2025 16:51
Copy link
Member

@zimeg zimeg left a 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.

Comment on lines +32 to +34
app types.App
collaborators []types.SlackUser
expectedOutputs []string
Copy link
Member

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.

Comment on lines 41 to 43
expectedOutputs: []string{
"0 collaborators",
},
Copy link
Member

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 🧪

Comment on lines 41 to 43
expectedOutputs: []string{
"0 collaborators",
},
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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".

Comment on lines 41 to 43
expectedOutputs: []string{
"0 collaborators",
},
Copy link
Member

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?

Comment on lines +84 to +96
expectedOutputs: []string{
"2 collaborators",
// User info: slackbot
"USLACKBOT",
"slackbot",
"[email protected]",
string(types.OWNER),
// User info: bookworm
"U00READER",
"bookworm",
"[email protected]",
string(types.READER),
},
Copy link
Member

Choose a reason for hiding this comment

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

📚 🪱 🤖 ✨

What an interesting app!

@mwbrooks mwbrooks merged commit 02eeb55 into main Apr 8, 2025
6 checks passed
@mwbrooks mwbrooks deleted the mbrooks-test-collaborator-list-output branch April 8, 2025 21:44
@mwbrooks
Copy link
Member Author

mwbrooks commented Apr 8, 2025

Thanks for the quick review and originally suggesting this change @zimeg! 🚀 🚀 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code health M-T: Test improvements and anything that improves code health semver:patch Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants