⚒️ Forge: [remove unwrap from docker tests]#1102
Conversation
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request refactors test assertions in src/env/docker.rs by replacing manual position checks and unwraps with the more idiomatic let ... else { panic!(...) } pattern, improving error reporting. The reviewer suggested an additional improvement to use windows(2) for checking the --network none argument sequence, which would make the test assertions more concise and readable.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| let Some(network_pos) = args.iter().position(|a| a == "--network") else { | ||
| panic!("expected --network flag in args: {args:?}"); | ||
| }; | ||
| assert_eq!(args.get(network_pos + 1).map(String::as_str), Some("none")); |
There was a problem hiding this comment.
For better conciseness and to more directly express the test's intent, you could use windows(2) to find the ["--network", "none"] slice in the arguments. This combines the search for --network and the check for the following argument into a single, more readable assertion.
assert!(
args.windows(2).any(|w| w[0] == "--network" && w[1] == "none"),
"expected --network none in args: {args:?}"
);
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #1102 +/- ##
=======================================
Coverage 86.63% 86.63%
=======================================
Files 139 139
Lines 86826 86826
=======================================
+ Hits 75220 75221 +1
+ Misses 11606 11605 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚮 Smell:
unwrap()calls in test assertions causingclippy::unwrap_usedwarnings.✨ Solution: Replaced
unwrap()calls withlet Some(...) = ... else { panic!(...) }guard clauses, providing explicit error messages.🧼 Benefit: Improves code clarity, strictly types the extraction, and gives better context on test failure compared to bare unwrap panics.
🛡️ Verification: Tests passed locally with no logical changes. Run
cargo fmt,cargo clippy, andcargo test env::docker.PR created automatically by Jules for task 3800413187454716517 started by @madmax983