-
Notifications
You must be signed in to change notification settings - Fork 0
test: Add codex file assertions to update integration and unit tests #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bfbbc1d
c4c564d
aeec9ff
e897309
7a5e2cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,25 @@ func TestIntegration_UpdatePreservesCustomizations(t *testing.T) { | |
| if !strings.Contains(updated, "WORKDIR /workspace\n\nFROM agentbox AS custom") { | ||
| t.Error("Dockerfile should have exactly one blank line between agentbox stage and custom stage") | ||
| } | ||
|
|
||
| // Verify codex files are regenerated after update. | ||
| codexConfig := readFile(t, filepath.Join(devDir, "codex-config.toml")) | ||
| if !strings.Contains(codexConfig, "approval_policy") { | ||
| t.Error("codex-config.toml should contain approval_policy after update") | ||
| } | ||
| if !strings.Contains(codexConfig, "sandbox_mode") { | ||
| t.Error("codex-config.toml should contain sandbox_mode after update") | ||
| } | ||
| if !strings.Contains(codexConfig, "apps = false") { | ||
| t.Error("codex-config.toml should contain apps = false after update") | ||
| } | ||
| syncCodex := readFile(t, filepath.Join(devDir, "sync-codex-settings.sh")) | ||
| if !strings.Contains(syncCodex, "codex-config.toml") { | ||
| t.Error("sync-codex-settings.sh should reference codex-config.toml after update") | ||
| } | ||
| if !strings.Contains(syncCodex, "$HOME/.codex") { | ||
| t.Error("sync-codex-settings.sh should reference $HOME/.codex after update") | ||
| } | ||
| } | ||
|
|
||
| func TestIntegration_UpdateWithStackChange(t *testing.T) { | ||
|
|
@@ -109,6 +128,33 @@ func TestIntegration_UpdateWithStackChange(t *testing.T) { | |
| if len(cfg.Stacks) != 2 { | ||
| t.Errorf("expected 2 stacks, got %d: %v", len(cfg.Stacks), cfg.Stacks) | ||
| } | ||
|
|
||
| // Verify codex files exist with expected content after stack change. | ||
| codexConfig := readFile(t, filepath.Join(devDir, "codex-config.toml")) | ||
| if !strings.Contains(codexConfig, "approval_policy") { | ||
| t.Error("codex-config.toml should contain approval_policy after stack change") | ||
| } | ||
| if !strings.Contains(codexConfig, "sandbox_mode") { | ||
| t.Error("codex-config.toml should contain sandbox_mode after stack change") | ||
| } | ||
| if !strings.Contains(codexConfig, "apps = false") { | ||
| t.Error("codex-config.toml should contain apps = false after stack change") | ||
| } | ||
| syncCodex := readFile(t, filepath.Join(devDir, "sync-codex-settings.sh")) | ||
| if !strings.Contains(syncCodex, "codex-config.toml") { | ||
| t.Error("sync-codex-settings.sh should reference codex-config.toml after stack change") | ||
| } | ||
| if !strings.Contains(syncCodex, "$HOME/.codex") { | ||
| t.Error("sync-codex-settings.sh should reference $HOME/.codex after stack change") | ||
| } | ||
|
|
||
| // Verify executable permissions on all scripts after update. | ||
| for _, name := range executableScripts { | ||
| info := assertFileExists(t, filepath.Join(devDir, name)) | ||
| if info.Mode().Perm()&0o111 == 0 { | ||
| t.Errorf("%s should be executable after update", name) | ||
| } | ||
| } | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [SUGGESTION] Force-mode codex assertions are weaker than the other tests. The |
||
| } | ||
|
|
||
| func TestIntegration_UpdateForceMode(t *testing.T) { | ||
|
|
@@ -160,6 +206,33 @@ func TestIntegration_UpdateForceMode(t *testing.T) { | |
| if !strings.Contains(updated, "USER CUSTOMIZATIONS") { | ||
| t.Error("Dockerfile should contain custom stage comments after --force") | ||
| } | ||
|
|
||
| // Verify executable permissions on all scripts after --force update. | ||
| for _, name := range executableScripts { | ||
| info := assertFileExists(t, filepath.Join(devDir, name)) | ||
| if info.Mode().Perm()&0o111 == 0 { | ||
| t.Errorf("%s should be executable after --force update", name) | ||
| } | ||
| } | ||
|
|
||
| // Verify codex files are regenerated during force mode. | ||
| codexConfig := readFile(t, filepath.Join(devDir, "codex-config.toml")) | ||
| if !strings.Contains(codexConfig, "approval_policy") { | ||
| t.Error("codex-config.toml should contain approval_policy after --force update") | ||
| } | ||
| if !strings.Contains(codexConfig, "sandbox_mode") { | ||
| t.Error("codex-config.toml should contain sandbox_mode after --force update") | ||
| } | ||
| if !strings.Contains(codexConfig, "apps = false") { | ||
| t.Error("codex-config.toml should contain apps = false after --force update") | ||
| } | ||
| syncCodex := readFile(t, filepath.Join(devDir, "sync-codex-settings.sh")) | ||
| if !strings.Contains(syncCodex, "codex-config.toml") { | ||
| t.Error("sync-codex-settings.sh should reference codex-config.toml after --force update") | ||
| } | ||
| if !strings.Contains(syncCodex, "$HOME/.codex") { | ||
| t.Error("sync-codex-settings.sh should reference $HOME/.codex after --force update") | ||
| } | ||
| } | ||
|
|
||
| func TestIntegration_UpdateIdempotent(t *testing.T) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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, andTestIntegration_UpdateForceModechecks onlylen > 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_policyin all three). The force-mode test is the weakest --len(codexConfig) == 0would only catch a completely empty file, not a partially rendered one.