Skip to content
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

🌱 fix sorting contributors before comparing in test #4455

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

spencerschrock
Copy link
Member

@spencerschrock spencerschrock commented Dec 12, 2024

What kind of change does this PR introduce?

test fix follow up of #4437

What is the current behavior?

The intention for the test was always to sort, but the wrong sort function was used. This led to an unsorted list, which was dependent on map iteration order, leading to flaky unit tests. This was reproducible with go test when passing a large --count option.

What is the new behavior (if this is a feature change)?**

The contributors are sorted correctly.

  • Tests for the changes have been added (for bug fixes/features)

Which issue(s) this PR fixes

See https://github.com/ossf/scorecard/actions/runs/12300084637/job/34327383076#step:9:26

--- FAIL: Test_listContributors (0.00s)
    --- FAIL: Test_listContributors/multiple_contributors (0.00s)
        contributors_test.go:126: contributorsHandler.setup() mismatch (-want +got):
              []clients.User{
              	{
            - 		Login:            "[email protected]",
            + 		Login:            "[email protected]",
              		Companies:        {"testOrg"},
              		Organizations:    nil,
            - 		NumContributions: 1,
            + 		NumContributions: 2,
              		ID:               0,
              		IsBot:            false,
              	},
              	{
            - 		Login:            "[email protected]",
            + 		Login:            "[email protected]",
              		Companies:        {"testOrg"},
              		Organizations:    nil,
            - 		NumContributions: 2,
            + 		NumContributions: 1,
              		ID:               0,
              		IsBot:            false,
              	},
              }
FAIL

Special notes for your reviewer

Does this PR introduce a user-facing change?

For user-facing changes, please add a concise, human-readable release note to
the release-note

(In particular, describe what changes users might need to make in their
application as a result of this pull request.)

NONE

The intention was always to sort, but the wrong sort function was used.
This led to an unsorted list, which was dependent on map iteration
order, leading to flaky unit tests. This was reproducible with go test
when passing a large --count option.

Signed-off-by: Spencer Schrock <[email protected]>
@spencerschrock spencerschrock requested a review from a team as a code owner December 12, 2024 16:39
@spencerschrock spencerschrock requested review from justaugustus and raghavkaul and removed request for a team December 12, 2024 16:39
Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.63%. Comparing base (353ed60) to head (54987c3).
Report is 82 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4455      +/-   ##
==========================================
+ Coverage   66.80%   68.63%   +1.82%     
==========================================
  Files         230      242      +12     
  Lines       16602    18032    +1430     
==========================================
+ Hits        11091    12376    +1285     
- Misses       4808     4848      +40     
- Partials      703      808     +105     

@justaugustus justaugustus merged commit 2409124 into ossf:main Dec 12, 2024
42 checks passed
@spencerschrock spencerschrock deleted the flake-test branch December 12, 2024 19:41
balteravishay pushed a commit to PrinceAsiedu/scorecard that referenced this pull request Jan 22, 2025
The intention was always to sort, but the wrong sort function was used.
This led to an unsorted list, which was dependent on map iteration
order, leading to flaky unit tests. This was reproducible with go test
when passing a large --count option.

Signed-off-by: Spencer Schrock <[email protected]>
Signed-off-by: balteravishay <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants