Skip to content

[Repo Assist] test(envvar): cover ExpandWithLookup nil-lookup fallback path - #4729

Merged
devantler merged 2 commits into
mainfrom
repo-assist/test-envvar-nil-lookup-coverage-1c2c49cc62228d88
May 14, 2026
Merged

[Repo Assist] test(envvar): cover ExpandWithLookup nil-lookup fallback path#4729
devantler merged 2 commits into
mainfrom
repo-assist/test-envvar-nil-lookup-coverage-1c2c49cc62228d88

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Add a test that covers the nil lookup branch in ExpandWithLookup, verifying that passing nil as the lookup function falls back to os.LookupEnv.

What has changed and why?

The ExpandWithLookup function has a defensive guard that replaces a nil lookup with os.LookupEnv. This branch was previously uncovered, leaving the package at 91.3% statement coverage. The new test exercises that path, improving coverage to 95.7%.

The remaining untested branch (len(groups) < minGroupsForVarName in expandMatch) is a defensive guard that cannot be triggered through the public API because the regex always produces the required number of groups on a match.

Type of change

  • 🧹 Refactor (test coverage improvement)

Test Status

go test -count=1 -cover ./pkg/envvar/... passes: 95.7% coverage (up from 91.3%)

Generated by 🤖 Repo Assist, see workflow run.

Add TestExpandWithLookup_NilLookupFallsBackToOsLookupEnv to verify that
passing nil as the lookup function falls back to os.LookupEnv, covering
the previously untested branch in ExpandWithLookup. Coverage for the
package improves from 91.3% to 95.7%.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 14, 2026 01:26

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions

Copy link
Copy Markdown
Contributor Author

MegaLinter analysis: Success

✅ Linters with no issues

actionlint, git_diff, hadolint, jscpd, jsonlint, lychee, markdown-table-formatter, markdownlint, prettier, prettier, stylelint, syft, trivy-sbom, trufflehog, v8r, v8r, yamllint

See detailed reports in MegaLinter artifacts

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@codecov

codecov Bot commented May 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@devantler
devantler marked this pull request as ready for review May 14, 2026 06:09
@devantler
devantler self-requested a review as a code owner May 14, 2026 06:09
Copilot AI review requested due to automatic review settings May 14, 2026 06:09

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@devantler
devantler added this pull request to the merge queue May 14, 2026
Merged via the queue into main with commit 5e62f07 May 14, 2026
90 of 115 checks passed
@devantler
devantler deleted the repo-assist/test-envvar-nil-lookup-coverage-1c2c49cc62228d88 branch May 14, 2026 09:08
@github-project-automation github-project-automation Bot moved this from 🫴 Ready to ✅ Done in 🌊 Project Board May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants