test: Add codex file assertions to update integration and unit tests - #37
Conversation
Add codex-config.toml and sync-codex-settings.sh content assertions, executable permission checks, and non-empty file assertions to the three update integration tests and the ForceRegeneration unit test.
BjRo
left a comment
There was a problem hiding this comment.
Go Code Review
Summary
This PR adds codex file assertions (codex-config.toml, sync-codex-settings.sh) to the update integration and unit tests. The changes are clean, well-structured, and follow the established testing patterns in the codebase. The assertions are placed logically within existing test functions, the readFile/assertFileExists helpers are reused correctly, and the executableScripts package-level slice is leveraged for permission checks rather than hardcoding file names.
A few observations on assertion consistency across the test functions -- nothing blocking.
Findings
[SUGGESTION] Inconsistent assertion depth for codex files across update integration tests. TestIntegration_UpdateWithStackChange checks three TOML keys (approval_policy, sandbox_mode, apps = false) and two sync-script references (codex-config.toml, $HOME/.codex), while TestIntegration_UpdatePreservesCustomizations only checks one of each, and TestIntegration_UpdateForceMode only checks non-emptiness. If the intent is to verify "codex files are correctly regenerated," the depth of assertion should match across all three tests. The force-mode test in particular would benefit from at least one content assertion (e.g., approval_policy) beyond the len > 0 check, since an empty-file guard is already provided by readFile calling t.Fatalf on read error.
[SUGGESTION] Unit test TestUpdateCommand_ForceRegeneration uses os.ReadFile directly while integration tests use readFile helper. This is fine since unit tests do not have access to the integration-test-only helper (build tag boundary), but it is worth noting that the readFile helper is defined in init_integration_test.go behind //go:build integration. If more unit tests need this pattern, extracting a shared readFile into a non-tagged test helper file would reduce duplication.
Verdict
LGTM -- the assertions are correct, follow project conventions, and fill a real coverage gap.
Automated review by Go Review Agent
| if !strings.Contains(codexConfig, "sandbox_mode") { | ||
| t.Error("codex-config.toml should contain sandbox_mode after stack change") | ||
| } | ||
| if !strings.Contains(codexConfig, "apps = false") { |
There was a problem hiding this comment.
[SUGGESTION] Inconsistent assertion depth across update integration tests.
TestIntegration_UpdateWithStackChange (lines 123-140) checks three TOML keys and two sync-script references, while this test checks only one of each, and TestIntegration_UpdateForceMode checks only len > 0. Consider aligning the assertion depth so each test that claims "codex files are regenerated" verifies at least the same baseline content (e.g., approval_policy in all three). The force-mode test is the weakest -- len(codexConfig) == 0 would only catch a completely empty file, not a partially rendered one.
| if info.Mode().Perm()&0o111 == 0 { | ||
| t.Errorf("%s should be executable after update", name) | ||
| } | ||
| } |
There was a problem hiding this comment.
[SUGGESTION] Force-mode codex assertions are weaker than the other tests.
The len(codexConfig) == 0 and len(syncCodex) == 0 checks here only guard against empty files. Since readFile already calls t.Fatalf on read error (covering the "file missing" case), these len checks add minimal value. A single content assertion like strings.Contains(codexConfig, "approval_policy") would make this consistent with the other two tests and actually verify the content was rendered, not just that bytes were written.
Codex Code ReviewThe Codex CLI review tool ( Error observed: No automated review output was produced. A manual re-run of the Codex review may be needed once the OpenAI API connectivity is restored. Automated review by Codex Review Agent |
Replace weak len==0 guards in force-mode test with actual content assertions (approval_policy, sandbox_mode, apps = false). Add missing sandbox_mode, apps = false, and $HOME/.codex checks to the preserves-customizations test so all three update tests verify the same baseline content.
BjRo
left a comment
There was a problem hiding this comment.
Go Code Review (Re-review)
Summary
Re-review after rework. The two SUGGESTION-level findings from the initial review have been addressed correctly:
-
Inconsistent assertion depth -- FIXED. All three integration tests (
TestIntegration_UpdatePreservesCustomizations,TestIntegration_UpdateWithStackChange,TestIntegration_UpdateForceMode) now assert the same five codex content properties:approval_policy,sandbox_mode,apps = falseincodex-config.toml, andcodex-config.toml/$HOME/.codexreferences insync-codex-settings.sh. The force-mode test previously only checked non-emptiness; it now has full content assertions matching the other two tests. -
Unit test
os.ReadFilevsreadFilehelper -- Acknowledged as acceptable given the build tag boundary. No change needed.
No new issues found. The assertions are consistent, the executable permission checks via executableScripts are correctly placed in both the stack-change and force-mode tests, and all tests pass (unit and integration).
Verdict
LGTM
Automated review by Go Review Agent
Codex Code ReviewThe Codex CLI review tool failed to produce output. The tool encountered repeated connection errors when attempting to reach the OpenAI API ( Tool details:
A manual re-review can be triggered once the API connectivity issue is resolved. Automated review by Codex Review Agent |
Codex Code ReviewThe changes only add test coverage, and the new assertions align with the current update/init behavior for Codex-generated files and script permissions. I did not identify any introduced bug or incorrect expectation in the modified tests.Automated review by Codex Review Agent |
…37) * test: Add codex file assertions to update integration and unit tests Add codex-config.toml and sync-codex-settings.sh content assertions, executable permission checks, and non-empty file assertions to the three update integration tests and the ForceRegeneration unit test. * chore: Update bean agentbox-comb checklist * chore: Mark branch pushed in bean agentbox-comb checklist * fix: Align codex assertion depth across update integration tests Replace weak len==0 guards in force-mode test with actual content assertions (approval_policy, sandbox_mode, apps = false). Add missing sandbox_mode, apps = false, and $HOME/.codex checks to the preserves-customizations test so all three update tests verify the same baseline content. * chore: Update bean agentbox-comb pipeline state (all phases done)
Summary
Closes agentbox-comb
Test plan
go test ./...passesgo test -tags integration ./cmd/...passesgolangci-lint run ./...clean🤖 Generated with Claude Code