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

Test the stats:fetch command, and report if Packagist download count fails #251

Merged
merged 5 commits into from
Nov 10, 2023

Conversation

gcavanunez
Copy link
Contributor

@gcavanunez gcavanunez commented Nov 6, 2023

Highlights

  • Tests stats:fetch command
  • Mocks HTTP and GitHub requests
  • Reports if 500 on Packagist

Notes

  • We try to fetch on all packages, regardless if they exist or not in packagist.org, which feel odd
  • If packagist.org, for whatever reason, fails to report, we would no longer overwrite download counts

reference

@mattstauffer mattstauffer changed the title chore: test stats:fetch cmd Test the stats:fetch command Nov 9, 2023
Copy link
Member

@mattstauffer mattstauffer left a comment

Choose a reason for hiding this comment

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

Great work! Just a few notes.

app/Console/Commands/FetchProjectStats.php Show resolved Hide resolved
}

/** @test */
public function fetch_stats_does_not_overwrite_packagist_stats(): void
Copy link
Member

Choose a reason for hiding this comment

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

If I'm understanding this test correctly, it means a failed request doesn't overwrite our local stats, right? If so, I'd change the method name to indicate this:

Suggested change
public function fetch_stats_does_not_overwrite_packagist_stats(): void
public function failed_stats_fetch_does_not_overwrite_packagist_stats(): void

'name' => 'existing_package',
'packagist_name' => null,
]);
$maintainer = Maintainer::factory()->create([
Copy link
Member

Choose a reason for hiding this comment

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

Maybe in another PR, but this feels silly to have to create the maintainer in this test when it isn't relevant to this test. Could we add a factory state (I think that's what they're called these days) for the project factory so we could just chain withMaintainer() when creating the project?

@mattstauffer mattstauffer changed the title Test the stats:fetch command Test the stats:fetch command, and report if Packagist download count fails Nov 9, 2023
@mattstauffer mattstauffer merged commit 238b050 into main Nov 10, 2023
@mattstauffer
Copy link
Member

Great work @gcavanunez!

@mattstauffer mattstauffer deleted the feat/throw-exception-if-packagist-fails branch November 10, 2023 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants