-
Notifications
You must be signed in to change notification settings - Fork 0
fix: test_recently_updated_package_names
test to provide a mock res…
#2
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
base: main
Are you sure you want to change the base?
Conversation
…ponse. Signed-off-by: gitworkflows <[email protected]>
🚨 gitStream Monthly Automation Limit Reached 🚨 Your organization has exceeded the number of pull requests allowed for automation with gitStream. To continue automating your PR workflows and unlock additional features, please contact LinearB. |
Reviewer's GuideRefactors the Maven test to stub the new Sonatype POST API endpoint with appropriate JSON payload and response fixture for recently updated packages. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
WalkthroughThe test for the Changes
Suggested labels
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
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.
Hey @gitworkflows - I've reviewed your changes - here's some feedback:
- Align the test’s expected package count with the actual number of entries in updated_packages.json (currently stubbed with size: 20 but asserting 100).
- Extract the POST body parameters and expected count into named variables or constants to avoid hard-coded magic numbers and improve maintainability.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Co-authored-by: qodo-merge-pro-for-open-source[bot] <189517486+qodo-merge-pro-for-open-source[bot]@users.noreply.github.com> Signed-off-by: gitworkflows <[email protected]>
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
test/models/ecosystem/maven_test.rb
(1 hunks)
🧰 Additional context used
🪛 GitHub Actions: CI
test/models/ecosystem/maven_test.rb
[error] 81-81: ArgumentError: the directory '/home/runner/work/packages/packages/test/fixtures/files' does not contain a file named 'maven/updated_packages.json'.
[error] 19-19: Test failure: Expected URL without trailing slash but got URL with trailing slash in 'test_registry_url_with_version'.
🔇 Additional comments (1)
test/models/ecosystem/maven_test.rb (1)
74-82
: LGTM! Proper API migration implementation.The migration from GET to POST request with JSON payload is correctly implemented:
- Appropriate Content-Type headers for JSON
- Correct request body structure with pagination and sorting parameters
- Proper response stubbing with JSON fixture
This aligns well with modern REST API practices for complex queries.
🧰 Tools
🪛 GitHub Actions: CI
[error] 81-81: ArgumentError: the directory '/home/runner/work/packages/packages/test/fixtures/files' does not contain a file named 'maven/updated_packages.json'.
test/models/ecosystem/maven_test.rb
Outdated
status: 200, | ||
body: file_fixture('maven/updated_packages.json'), # Create a fixture file with mock data | ||
headers: { 'Content-Type' => 'application/json' } | ||
) | ||
recently_updated_package_names = @ecosystem.recently_updated_package_names | ||
assert_equal recently_updated_package_names.length, 100 |
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.
💡 Verification agent
🧩 Analysis chain
Verify the fixture data matches the expected count.
Ensure that when you create the maven/updated_packages.json
fixture file, it contains exactly 100 package names to match this assertion. The fixture should have a structure that the recently_updated_package_names
method can parse to extract the package names.
🏁 Script executed:
#!/bin/bash
# Description: Check if the fixture file exists and verify the Maven ecosystem implementation
# Expected: Find the recently_updated_package_names method implementation to understand the expected JSON structure
# Check if the fixture file exists
fd "updated_packages.json" test/fixtures/files/maven/
# Find the implementation of recently_updated_package_names to understand expected JSON structure
ast-grep --pattern $'def recently_updated_package_names
$$$
end'
Length of output: 14341
🏁 Script executed:
#!/usr/bin/env bash
set -eux
# 1. Verify the fixture file exists
fd "updated_packages.json" -t f -p test/fixtures/files/maven/
# 2. Preview the fixture to see its structure
head -n 20 test/fixtures/files/maven/updated_packages.json
# 3. Count entries in the fixture (handles both array root or {"packages": [...]})
jq 'if type=="array" then length elif .packages then .packages|length else 0 end' test/fixtures/files/maven/updated_packages.json
# 4. Show the test around the assertion for context
sed -n '1,120p' test/models/ecosystem/maven_test.rb
Length of output: 240
🏁 Script executed:
#!/usr/bin/env bash
set -eux
# Locate the Maven fixture file anywhere in the repo
fd -t f updated_packages.json
# For each found file, show its beginning and count entries
for file in $(fd -t f updated_packages.json); do
echo "=== $file ==="
head -n 5 "$file"
jq 'if type=="array" then length elif .packages then .packages|length else 0 end' "$file"
done
# Show the Maven test context around the assertion
sed -n '1,120p' test/models/ecosystem/maven_test.rb
Length of output: 5870
Add the missing Maven updated_packages.json
fixture with 100 entries
The test for recently_updated_package_names
stubs the Sonatype API response using file_fixture('maven/updated_packages.json')
, but that file isn’t present. To get the assertion
assert_equal recently_updated_package_names.length, 100
to pass, you need to:
- Create
test/fixtures/files/maven/updated_packages.json
- Populate it with a JSON payload matching what
recently_updated_package_names_from_sonatype
expects (e.g. the Sonatype API’scomponents
array structure) - Include exactly 100 unique package entries so that
.length
returns 100 - (Optional) Reference Sonatype’s API docs or inspect
app/models/ecosystem/maven.rb
to confirm the correct JSON keys
Once the fixture file exists and is formatted correctly, the test at test/models/ecosystem/maven_test.rb
line 85 will pass.
🤖 Prompt for AI Agents
In test/models/ecosystem/maven_test.rb at line 85, the test asserts that
recently_updated_package_names returns 100 entries, but the fixture file
test/fixtures/files/maven/updated_packages.json is missing. To fix this, create
the updated_packages.json fixture file with a JSON structure matching what
recently_updated_package_names_from_sonatype expects (likely including a
"components" array), and ensure it contains exactly 100 unique package entries
so the length assertion passes.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: gitworkflows <[email protected]>
Signed-off-by: gitworkflows <[email protected]>
…ponse.
Addresses issue: #
Changes proposed in this pull request:
Summary by Sourcery
Update the Maven ecosystem test to stub the new Sonatype API POST endpoint with a JSON fixture for recently updated package names
Bug Fixes:
Tests:
updated_packages.json
fixture and JSON content-type header in the stubbed responseSummary by CodeRabbit