Skip to content

⚒️ Forge: [remove unwrap from docker tests]#1102

Closed
madmax983 wants to merge 1 commit into
trunkfrom
forge-remove-unwrap-docker-tests-3800413187454716517
Closed

⚒️ Forge: [remove unwrap from docker tests]#1102
madmax983 wants to merge 1 commit into
trunkfrom
forge-remove-unwrap-docker-tests-3800413187454716517

Conversation

@madmax983

Copy link
Copy Markdown
Owner

🚮 Smell: unwrap() calls in test assertions causing clippy::unwrap_used warnings.
✨ Solution: Replaced unwrap() calls with let 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, and cargo test env::docker.


PR created automatically by Jules for task 3800413187454716517 started by @madmax983

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 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.

Comment thread src/env/docker.rs
Comment on lines +532 to +535
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"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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:?}"
        );

@madmax983 madmax983 closed this Jul 17, 2026
@madmax983
madmax983 deleted the forge-remove-unwrap-docker-tests-3800413187454716517 branch July 17, 2026 00:14
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.63%. Comparing base (33594d5) to head (f7619ae).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant