-
Notifications
You must be signed in to change notification settings - Fork 7
add json tags to PackageInfo struct and tests #40
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
toolchain would not download with go get Changelog: fixed
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThis PR updates the Go module go version in Changes
Sequence Diagram(s)(omitted — changes are structural/serialization-only and do not modify runtime control flow) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧬 Code graph analysis (1)manager/packageinfo.go (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (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. Comment |
Summary of ChangesHello @aijanai, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on improving the JSON serialization of the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Caution
Changes requested ❌
Reviewed everything up to 0874811 in 1 minute and 45 seconds. Click for details.
- Reviewed
90lines of code in3files - Skipped
0files when reviewing. - Skipped posting
1draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. go.mod:3
- Draft comment:
Using 'go 1.23.0' instead of '1.23' meets the toolchain download requirement. Ensure that this format is consistently documented across the project. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
Workflow ID: wflow_6PplkVkFl0VMFQqn
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
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.
Code Review
This pull request correctly adds JSON tags to the PackageInfo struct and fixes the Go version in go.mod. The addition of tests for the JSON tags is a great initiative. I've provided a couple of suggestions to improve the implementation. One suggestion is to use omitempty in the JSON tags to create a more compact JSON output for optional fields. The other is a rewrite of the new test to make it more robust and correct, as the current version has a few issues.
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
🧹 Nitpick comments (1)
manager/packageinfo_test.go (1)
17-18: Consider strengthening the test validation.The current test only checks if tag strings appear anywhere in the JSON output. A more robust approach would verify they appear as actual JSON keys.
Consider using
json.Unmarshalinto amap[string]interface{}to verify the exact keys:func TestPackageInfoJsonTag(t *testing.T) { testPackage := PackageInfo{} jsonAsByte, err := json.Marshal(testPackage) if err != nil { t.Fatalf("Failed to marshal PackageInfo: %v", err) } var jsonMap map[string]interface{} if err := json.Unmarshal(jsonAsByte, &jsonMap); err != nil { t.Fatalf("Failed to unmarshal JSON: %v", err) } expectedKeys := []string{"name", "version", "new_version", "status", "category", "arch", "package_manager", "additional_data"} for _, key := range expectedKeys { if _, exists := jsonMap[key]; !exists { t.Errorf("Expected key '%s' not found in JSON: %v", key, jsonMap) } } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
go.mod(1 hunks)manager/packageinfo.go(1 hunks)manager/packageinfo_test.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
manager/packageinfo.go (1)
interface.go (1)
PackageManager(6-72)
🔇 Additional comments (2)
manager/packageinfo.go (1)
55-88: LGTM! JSON tags are correctly applied.All eight exported fields now have appropriate JSON struct tags using consistent snake_case naming. This improves JSON serialization consistency and is a good practice for cross-language data interchange. The changes are non-breaking and only affect how the struct is serialized to JSON.
go.mod (1)
3-3: Go version format update verified and approved.The change from
go 1.23togo 1.23.0is valid and properly recognized by Go's module system. Verification confirmsgo mod verifypasses successfully with the updated format, demonstrating that the explicit patch version is supported by Go tooling.
checks for tag usage Changelog: added
Changelog: added
|
@bluet at your convenience :) |
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.
Pull Request Overview
This PR adds JSON serialization tags to the PackageInfo struct to ensure proper JSON field naming (snake_case) and adds corresponding tests to verify the tags are correctly applied. It also fixes the Go version specification in go.mod.
Key Changes
- Added JSON tags with snake_case naming to all
PackageInfostruct fields - Created comprehensive test to validate JSON serialization and field presence
- Fixed Go version from
1.23to1.23.0for proper toolchain download
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| manager/packageinfo.go | Added JSON tags to PackageInfo struct fields with snake_case naming and omitempty for optional fields |
| manager/packageinfo_test.go | Added new test TestPackageInfoJsonTag to verify JSON tag presence and correct serialization |
| go.mod | Fixed Go version specification from 1.23 to 1.23.0 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
json should have low case, underscore separated names.
Add tests that verify that the tags have been used
Fix a missing
.0in the go version, that prevented successful download of toolchainChangelog: added
Important
Add JSON tags to
PackageInfostruct and tests to verify serialization, and fix Go version ingo.mod.PackageInfostruct fields inpackageinfo.gofor proper serialization.TestPackageInfoJsonTaginpackageinfo_test.goto verify JSON tags are applied.go.modfrom1.23to1.23.0.This description was created by
for 0874811. You can customize this summary. It will automatically update as commits are pushed.
Summary by CodeRabbit
Improvements
Chores
Tests