-
Notifications
You must be signed in to change notification settings - Fork 12
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: add test for duplicated jobs #112
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request introduces a new test module for the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
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: 0
🧹 Nitpick comments (1)
crates/gh-workflow/src/generate.rs (1)
169-185
: Excellent negative scenario test.The
missing_add_job
test covers the scenario where the base job is not initially added to the workflow. This ensures that theorganize_job_dependency
logic properly creates the missing job and updates dependencies. The snapshot approach effectively validates this behavior.As a future enhancement, consider adding more corner cases (e.g., circular dependencies or multiple missing dependencies) to further strengthen coverage.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
crates/gh-workflow/src/snapshots/gh_workflow__generate__tests__add_needs_job.snap
is excluded by!**/*.snap
crates/gh-workflow/src/snapshots/gh_workflow__generate__tests__missing_add_job.snap
is excluded by!**/*.snap
📒 Files selected for processing (1)
crates/gh-workflow/src/generate.rs
(1 hunks)
🔇 Additional comments (3)
crates/gh-workflow/src/generate.rs (3)
144-145
: Good approach enabling test mode.
The addition of #[cfg(test)]
and the tests
module helps maintain a clear separation between production and test code, ensuring that tests are only compiled and run in test mode. This is a best practice in Rust.
146-148
: Using insta
for snapshot testing and use super::*
is effective.
Snapshot testing with insta
can quickly catch unintentional changes, and importing from the parent module (use super::*
) helps referencing the tested items directly. This setup is concise and robust.
150-167
: Thorough test for existing job dependencies.
The add_needs_job
test effectively covers the scenario where the base job is included in the workflow from the start. It ensures that the final generated workflow correctly reflects the dependencies. Consider also verifying the resulting YAML structure by asserting specific keys or fields within the snapshot if you need granular checks.
Summary by CodeRabbit