Skip to content

test: Isolate wizard config files - #5207

Open
iverc wants to merge 1 commit into
developfrom
iverc/4682-test-config-tempdir
Open

test: Isolate wizard config files#5207
iverc wants to merge 1 commit into
developfrom
iverc/4682-test-config-tempdir

Conversation

@iverc

@iverc iverc commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Relevant issue(s)

Resolves #4682

Description

Makes the shared wizard test helper assign a temporary root directory whenever a test context does not provide one. This prevents configuration reads and writes from creating config.yaml in the package checkout.

Adds a regression test for the temporary-root fallback. Production behavior and dependencies are unchanged.

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style.
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, and resource requirements.

How has this been tested?

  • go test ./cli/wizard -run TestSetConfigValueForTestUsesTemporaryRoot -count=1
  • go test ./cli/wizard -skip SystemKeyring -count=1
  • Verified the test run leaves no config.yaml in the worktree

Tested on macOS.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 090ad558-68ed-48e0-8015-4604c045fb0e

📥 Commits

Reviewing files that changed from the base of the PR and between c732d45 and ac84cbd.

📒 Files selected for processing (1)
  • cli/wizard/utils_test.go

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (52)
  • GitHub Check: Build, install, and test Debian package
  • GitHub Check: Start binary job
  • GitHub Check: Test macos job
  • GitHub Check: Test Limited Resource job
  • GitHub Check: Test coverage job (go, file, gql)
  • GitHub Check: Test coverage job (c, memory, collection-save)
  • GitHub Check: Test coverage job (c, file, gql)
  • GitHub Check: Test coverage job (cli, memory, collection-named)
  • GitHub Check: Test coverage job (go, memory, gql)
  • GitHub Check: Test coverage job (http, memory, collection-named)
  • GitHub Check: Test coverage job (go, memory, collection-named)
  • GitHub Check: Test coverage job (http, file, gql)
  • GitHub Check: Test coverage job (cli, file, collection-named)
  • GitHub Check: Test coverage job (c, file, collection-save)
  • GitHub Check: Test coverage job (cli, file, collection-save)
  • GitHub Check: Test coverage job (c, memory, gql)
  • GitHub Check: Test coverage job (cli, memory, collection-save)
  • GitHub Check: Test coverage job (http, memory, gql)
  • GitHub Check: Test coverage job (cli, file, gql)
  • GitHub Check: Test coverage job (c, file, collection-named)
  • GitHub Check: Test coverage job (c, memory, collection-named)
  • GitHub Check: Test coverage job (http, file, collection-named)
  • GitHub Check: Test coverage job (go, file, collection-named)
  • GitHub Check: Test coverage job (cli, memory, gql)
  • GitHub Check: Test coverage job (go, file, collection-save)
  • GitHub Check: Test coverage job (http, memory, collection-save)
  • GitHub Check: Test coverage job (http, file, collection-save)
  • GitHub Check: Test coverage document acp job (cli, source-hub)
  • GitHub Check: Test coverage job (go, memory, collection-save)
  • GitHub Check: Check wire format changes job
  • GitHub Check: Test coverage document acp job (c, source-hub)
  • GitHub Check: Test coverage telemetry job
  • GitHub Check: Test coverage signed docs job
  • GitHub Check: Test coverage lens job (wazero)
  • GitHub Check: Test coverage secondary index job
  • GitHub Check: Test coverage document acp job (http, source-hub)
  • GitHub Check: Test coverage leveldb job
  • GitHub Check: Test coverage view job
  • GitHub Check: Check wizard health job
  • GitHub Check: Test coverage JS job
  • GitHub Check: Test coverage document acp job (go, source-hub)
  • GitHub Check: Check vulnerabilities job
  • GitHub Check: Check mocks job
  • GitHub Check: Test coverage encryption job
  • GitHub Check: Check http documentation job
  • GitHub Check: Test NPX/JS build job
  • GitHub Check: Lint GoLang job
  • GitHub Check: Validate containerfile job
  • GitHub Check: Check cli documentation job
  • GitHub Check: Check data format changes job
  • GitHub Check: Build and test Linux C shared library
  • GitHub Check: Lint GoLang job
⚠️ CI failures not shown inline (2)

GitHub Actions: Build Dependencies Workflow / 0_Build dependencies job.txt: test: Isolate wizard config files

Conclusion: failure

View job details

##[group]Run make deps
 �[36;1mmake deps�[0m
 shell: /usr/bin/bash -e {0}
 env:
   GOTOOLCHAIN: local
 ##[endgroup]
 ----------------------------------------
 OS = Linux
 PACKAGE_MANAGER = apt
 GOINFO = go version go1.25.13 linux/amd64
 GITCOMMIT = 174ad04c8d931267153c4f4af4a5ed86f966c108
 GITCOMMITDATE = 2026-08-31
 GITRELEASE = dev-
 ----------------------------------------
 ----------------------------------------
 OS = Linux
 PACKAGE_MANAGER = apt
 GOINFO = go version go1.25.13 linux/amd64
 GITCOMMIT = 174ad04c8d931267153c4f4af4a5ed86f966c108
 GITCOMMITDATE = 2026-08-31
 GITRELEASE = dev-
 ----------------------------------------
 go mod download
 ----------------------------------------
 OS = Linux
 PACKAGE_MANAGER = apt
 GOINFO = go version go1.25.13 linux/amd64
 GITCOMMIT = 174ad04c8d931267153c4f4af4a5ed86f966c108
 GITCOMMITDATE = 2026-08-31
 GITRELEASE = dev-
 ----------------------------------------
 go install golang.org/x/perf/cmd/benchstat@latest
 go: downloading golang.org/x/perf v0.0.0-20260825160852-19be9d8e6c70
 go: golang.org/x/perf/cmd/benchstat@latest: golang.org/x/perf@v0.0.0-20260825160852-19be9d8e6c70 requires go >= 1.26.0 (running go 1.25.13; GOTOOLCHAIN=local)
 make[1]: *** [Makefile:166: deps:bench] Error 1
 make: *** [Makefile:196: deps] Error 2
 ##[error]Process completed with exit code 2.

GitHub Actions: Build Dependencies Workflow / Build dependencies job: test: Isolate wizard config files

Conclusion: failure

View job details

##[group]Run make deps
 �[36;1mmake deps�[0m
 shell: /usr/bin/bash -e {0}
 env:
   GOTOOLCHAIN: local
 ##[endgroup]
 ----------------------------------------
 OS = Linux
 PACKAGE_MANAGER = apt
 GOINFO = go version go1.25.13 linux/amd64
 GITCOMMIT = 174ad04c8d931267153c4f4af4a5ed86f966c108
 GITCOMMITDATE = 2026-08-31
 GITRELEASE = dev-
 ----------------------------------------
 ----------------------------------------
 OS = Linux
 PACKAGE_MANAGER = apt
 GOINFO = go version go1.25.13 linux/amd64
 GITCOMMIT = 174ad04c8d931267153c4f4af4a5ed86f966c108
 GITCOMMITDATE = 2026-08-31
 GITRELEASE = dev-
 ----------------------------------------
 go mod download
 ----------------------------------------
 OS = Linux
 PACKAGE_MANAGER = apt
 GOINFO = go version go1.25.13 linux/amd64
 GITCOMMIT = 174ad04c8d931267153c4f4af4a5ed86f966c108
 GITCOMMITDATE = 2026-08-31
 GITRELEASE = dev-
 ----------------------------------------
 go install golang.org/x/perf/cmd/benchstat@latest
 go: downloading golang.org/x/perf v0.0.0-20260825160852-19be9d8e6c70
 go: golang.org/x/perf/cmd/benchstat@latest: golang.org/x/perf@v0.0.0-20260825160852-19be9d8e6c70 requires go >= 1.26.0 (running go 1.25.13; GOTOOLCHAIN=local)
 make[1]: *** [Makefile:166: deps:bench] Error 1
 make: *** [Makefile:196: deps] Error 2
 ##[error]Process completed with exit code 2.
🔇 Additional comments (1)
cli/wizard/utils_test.go (1)

17-17: LGTM!

Also applies to: 41-43, 54-62


📝 Walkthrough

Walkthrough

The test helper now assigns an automatic temporary root when WizardContext.RootDir is empty. A new test verifies that config.yaml is created under that temporary directory.

Changes

Temporary configuration root

Layer / File(s) Summary
Temporary root assignment and test validation
cli/wizard/utils_test.go
setConfigValueForTest uses t.TempDir() for an empty RootDir. The test verifies that config.yaml is created under the temporary root.

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: ⚪ Minimal · up to ac84c

This change isolates wizard test configuration in automatically cleaned temporary directories without affecting production behavior or dependencies; no actionable merge-blocking risk remains after normal checks and review.

Assessment Against Linked Issues

Objective Addressed Explanation
Use a temporary directory for test configuration writes [#4682]
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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.

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.45%. Comparing base (c732d45) to head (ac84cbd).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5207      +/-   ##
===========================================
+ Coverage    76.39%   76.45%   +0.06%     
===========================================
  Files          647      647              
  Lines        51690    51690              
===========================================
+ Hits         39486    39517      +31     
+ Misses        8874     8852      -22     
+ Partials      3330     3321       -9     
Flag Coverage Δ
all-tests 76.45% <ø> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 8 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c732d45...ac84cbd. Read the comment docs.

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

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

The fix is legit but the test coverage gives me mixed feelings

Comment thread cli/wizard/utils_test.go
Comment on lines +54 to +61
func TestSetConfigValueForTestUsesTemporaryRoot(t *testing.T) {
ctx := &WizardContext{}
setConfigValueForTest(t, ctx, "keyring.namespace", "test")

if _, err := os.Stat(filepath.Join(ctx.RootDir, "config.yaml")); err != nil {
t.Fatalf("expected config in temporary root: %v", err)
}
}

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.

suggestion: you cover with tests and internal helper function for tests. This looks unconventional. I'd remove it

@ChrisBQu ChrisBQu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Thanks for this.

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.

Temp config.yaml is created during tests

3 participants