Skip to content

Conversation

@mwbrooks
Copy link
Member

@mwbrooks mwbrooks commented Apr 4, 2025

Summary

This pull request fixes a flaky test in cmd/collaborators.go.

Previously, the test would only pass when other package collaborators tests ran first. After looking into the test, I realized that the test was outdated. Since the collaborators command executes collaborators list under the hood, I copied the table test from collaborators 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 4, 2025
@mwbrooks mwbrooks added this to the Next Release milestone Apr 4, 2025
@mwbrooks mwbrooks self-assigned this Apr 4, 2025
@codecov
Copy link

codecov bot commented Apr 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.83%. Comparing base (69fe8b9) to head (f82b1b9).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #14      +/-   ##
==========================================
+ Coverage   62.80%   62.83%   +0.03%     
==========================================
  Files         210      210              
  Lines       22053    22053              
==========================================
+ Hits        13850    13858       +8     
+ Misses       7126     7119       -7     
+ Partials     1077     1076       -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.

err := cmd.Execute()
if err != nil {
assert.Fail(t, "cmd.Execute had unexpected error")
tests := map[string]struct {
Copy link
Member Author

Choose a reason for hiding this comment

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

This test is a copy and paste of cmd/collaborators/list_test.go with one small change that I mention as a GitHub reviewer comment

clients.SDKConfig = hooks.NewSDKConfigMock()
})

err := NewCommand(clients).Execute()
Copy link
Member Author

Choose a reason for hiding this comment

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

Changed this from NewListCommand(clients).Execute() to NewCommand(clinets).Execute().

@mwbrooks mwbrooks marked this pull request as ready for review April 4, 2025 21:52
@mwbrooks mwbrooks requested a review from a team as a code owner April 4, 2025 21:52
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.

@mwbrooks Even as a "copy and paste" of other tests, this is such a wonderful improvement to the health of this code.

Adding new tests becomes more familiar and we're also testing more of the actual collaborators command which is great.

I feel lucky too since I hadn't experienced this flake, but I imagine debugging it was no fun task 🫡

I'm approving this now but left one comment around additional checks that we might want to make in this PR or in another PR with future changes if it seems unrelated to this! 🚢 ✨

Comment on lines +95 to +102
for _, collaborator := range tt.Collaborators {
clientsMock.IO.AssertCalled(t, "PrintTrace", mock.Anything, slacktrace.CollaboratorListCollaborator, []string{
collaborator.ID,
collaborator.UserName,
collaborator.Email,
string(collaborator.PermissionType),
})
}
Copy link
Member

Choose a reason for hiding this comment

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

👾 I like that we're checking the stable value used in tests here instead of stdout although I do wonder if we should make note of this to follow back up on?

I don't expect these outputs to change so often, but confirming certain values are output is somewhat nice in unit tests and IMO not so much of a hassle to update when changing related code.

No blocker at all but avoiding regression is a constant on mind ✨

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point! I can follow-up with another PR that updates this test for both collaborators and collaborators list 👌🏻

@mwbrooks
Copy link
Member Author

mwbrooks commented Apr 7, 2025

@zimeg Thanks for the quick review! It's always nice to merge these small fixes that make it a little more stable to run the tests. I'll follow-up with another small PR that adds assertions for the output based on your suggestion 🧪

@mwbrooks mwbrooks merged commit 3c995d5 into main Apr 7, 2025
6 checks passed
@mwbrooks mwbrooks deleted the mbrooks-fix-flaky-collaborator-test branch April 7, 2025 14:50
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