Skip to content

Test Improvement: Enhance coverage and edge case handling in internal/config - #416

Merged
Tei1988 merged 2 commits into
mainfrom
test-improvement-config-4823758916891471198
Jun 20, 2026
Merged

Test Improvement: Enhance coverage and edge case handling in internal/config#416
Tei1988 merged 2 commits into
mainfrom
test-improvement-config-4823758916891471198

Conversation

@Tei1988

@Tei1988 Tei1988 commented Jun 17, 2026

Copy link
Copy Markdown
Owner

This change significantly improves the quality and robustness of the internal/config package by expanding the test suite to cover various edge cases, boundary conditions, and error paths. It specifically focuses on value resolution, security boundaries, and path validation, ensuring that cderun behaves correctly in complex and nested execution environments.


PR created automatically by Jules for task 4823758916891471198 started by @Tei1988

Summary by CodeRabbit

リリースノート

  • Tests
    • 式処理のカバレッジを拡張し、アンカー検出のケースや共有状態未設定時のエラー、ネストした式の解決を検証するテストを追加しました。
    • パス/バリデータの網羅テストと、パス解決における追加の失敗分岐テストを追加しました。
    • 解決補助処理(環境値の解決、マウント解決)のエラー返却をサブテストで検証しました。

- Add exhaustive tests for path and configuration validators.
- Add complex nested expression and default value resolution tests.
- Increase coverage for environment and mount resolution helpers.
- Fix various edge cases in path resolution and expression evaluation tests.

Co-authored-by: Tei1988 <4068043+Tei1988@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.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 460f8709-288b-4ad3-8172-2c583cc8a591

📥 Commits

Reviewing files that changed from the base of the PR and between c7c1caf and e5c92f3.

📒 Files selected for processing (2)
  • internal/config/path_extra_coverage_test.go
  • internal/config/resolver_extra_coverage_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/config/path_extra_coverage_test.go
  • internal/config/resolver_extra_coverage_test.go

Walkthrough

internal/config パッケージの3つのテストファイルに計295行のユニットテストを追加した。式処理(scanAnchorsresolveFile・ネスト式解決)、パスバリデータ(ValidateEnvKey など4関数と isNamedVolume)、リゾルバヘルパ(resolveEnvValuesresolveMounts)のエラー分岐と正常系を網羅する。

Changes

config パッケージのテストカバレッジ拡張

Layer / File(s) Summary
式処理のカバレッジ拡張テスト
internal/config/expression_coverage_extension_test.go
scanAnchors のネスト・不一致括弧ケース、resolveFile の共有状態未設定エラー、ネストした env/file 式の多段解決挙動を検証するテスト関数3件を追加した。
パスバリデータの網羅的テストとエラーパスの検証
internal/config/path_extra_coverage_test.go
ValidateEnvKey/ValidatePort/ValidateWorkdir/ValidateToolName/isNamedVolume の表駆動テストと、ResolvePath 系ヘルパの複数失敗パス(YAML デコード・ホーム展開・不正文字・ボリューム解決・アンカー境界)をモック注入で検証するテスト関数2件を追加した。
リゾルバヘルパのエラーパステスト
internal/config/resolver_extra_coverage_test.go
resolveEnvValuesReadFileErr 失敗と resolveMountsStat 失敗をサブテストで検証する TestUnit_ResolverHelpers_Coverage を追加した。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

テストが増えて、コードが輝く ✨
モックを仕込み、エラーを捕まえ 🪤
nil が返るか、エラーか確かめ
バリデータたちも整列完了 🎖️
カバレッジの旗を高く掲げよう 🚩

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、変更内容の主要なポイント(internal/configパッケージのテストカバレッジ向上とエッジケース処理)を明確かつ簡潔に要約しており、チームメンバーが変更内容を迅速に理解できるものになっています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/config/path_extra_coverage_test.go`:
- Around line 166-202: The test "ResolvePath expandHome error" contains an
unused ResolvePath call on line 177 that calls ResolvePath with "~/foo",
"/base", and nil, which does not verify the result and gets overwritten by the
subsequent ResolvePath call. Remove this unused ResolvePath call and keep only
the second call to ResolvePath with "{{env:HOME_VAL}}" that actually tests the
expandHome error path with the mocked filesystem, as the first call does not
contribute to testing the intended expandHome error scenario.
- Around line 204-208: Replace `assert.Error` with `require.Error` on lines 206,
218, 222, 231, and 237 in the validatePathChars test function and similar test
cases. The issue is that when an error check is immediately followed by calling
`err.Error()` on that error variable, using `assert.Error` allows the test to
continue even if the error is nil, which will cause a panic when trying to call
methods on the nil error. Using `require.Error` instead will stop test execution
immediately if the assertion fails, preventing subsequent calls to `err.Error()`
on a nil value and ensuring test stability.

In `@internal/config/resolver_extra_coverage_test.go`:
- Line 116: Replace the `assert.Error` calls with `require.Error` on both line
116 and line 122 in the test file. The testifylint(require-error) rule requires
that error assertions use `require.Error` instead of `assert.Error` to provide
immediate test failure and termination when an error assertion fails, making
test intent clearer and debugging easier.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a5f1405b-b04d-4ec9-b725-0c35ef7d40e5

📥 Commits

Reviewing files that changed from the base of the PR and between f8decc3 and c7c1caf.

📒 Files selected for processing (3)
  • internal/config/expression_coverage_extension_test.go
  • internal/config/path_extra_coverage_test.go
  • internal/config/resolver_extra_coverage_test.go

Comment thread internal/config/path_extra_coverage_test.go
Comment thread internal/config/path_extra_coverage_test.go
Comment thread internal/config/resolver_extra_coverage_test.go Outdated
- Remove redundant ResolvePath call in expandHome error test.
- Upgrade assert.Error to require.Error in critical error paths to prevent panics and improve stability.
- Ensure proper variable scoping in test sub-runs.
- Finalize exhaustive validator and expression resolution tests.

Co-authored-by: Tei1988 <4068043+Tei1988@users.noreply.github.com>
@Tei1988

Tei1988 commented Jun 19, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Tei1988

Tei1988 commented Jun 19, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Tei1988

Tei1988 commented Jun 19, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Tei1988
Tei1988 merged commit 2f5e56a into main Jun 20, 2026
3 checks passed
@Tei1988
Tei1988 deleted the test-improvement-config-4823758916891471198 branch June 20, 2026 04:39
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