Files
CLIProxyAPI/internal/config/codex_websocket_header_defaults_test.go
Luis Pater 48686ccc8f feat(config): preserve unknown nested fields as comments during v8 migration
- Traverse nested configuration paths to comment out unrecognized fields during v8 migration
- Remove deprecated Codex `identity-confuse` configuration option and request handling
- Clean up identity confuse mapping logic from Codex HTTP and WebSocket executors
2026-09-28 10:46:32 +08:00

90 lines
2.3 KiB
Go

package config
import (
"os"
"path/filepath"
"testing"
)
func TestLoadConfigOptional_CodexHeaderDefaults(t *testing.T) {
dir := t.TempDir()
configPath := filepath.Join(dir, "config.yaml")
configYAML := []byte(`
codex-header-defaults:
user-agent: " my-codex-client/1.0 "
beta-features: " feature-a,feature-b "
`)
if err := os.WriteFile(configPath, configYAML, 0o600); err != nil {
t.Fatalf("failed to write config: %v", err)
}
cfg, err := LoadConfigOptional(configPath, false)
if err != nil {
t.Fatalf("LoadConfigOptional() error = %v", err)
}
if got := cfg.CodexHeaderDefaults.UserAgent; got != "my-codex-client/1.0" {
t.Fatalf("UserAgent = %q, want %q", got, "my-codex-client/1.0")
}
if got := cfg.CodexHeaderDefaults.BetaFeatures; got != "feature-a,feature-b" {
t.Fatalf("BetaFeatures = %q, want %q", got, "feature-a,feature-b")
}
if cfg.Codex.DisableCodexCloaking {
t.Fatal("DisableCodexCloaking = true, want default false")
}
}
func TestLoadConfigOptional_CodexOptions(t *testing.T) {
dir := t.TempDir()
configPath := filepath.Join(dir, "config.yaml")
configYAML := []byte(`
codex:
disable-codex-cloaking: true
optimize-multi-agent-v2: true
`)
if err := os.WriteFile(configPath, configYAML, 0o600); err != nil {
t.Fatalf("failed to write config: %v", err)
}
cfg, err := LoadConfigOptional(configPath, false)
if err != nil {
t.Fatalf("LoadConfigOptional() error = %v", err)
}
if !cfg.Codex.DisableCodexCloaking {
t.Fatal("DisableCodexCloaking = false, want true")
}
if !cfg.Codex.OptimizeMultiAgentV2 {
t.Fatalf("OptimizeMultiAgentV2 = false, want true")
}
}
func TestLoadConfigOptional_CodexModelLevelCooling(t *testing.T) {
dir := t.TempDir()
configPath := filepath.Join(dir, "config.yaml")
configYAML := []byte(`
codex:
model-level-cooling: true
`)
if err := os.WriteFile(configPath, configYAML, 0o600); err != nil {
t.Fatalf("failed to write config: %v", err)
}
cfg, err := LoadConfigOptional(configPath, false)
if err != nil {
t.Fatalf("LoadConfigOptional() error = %v", err)
}
if !cfg.Codex.ModelLevelCooling {
t.Fatalf("ModelLevelCooling = false, want true")
}
defaultCfg, errDefault := ParseConfigBytes([]byte(`{}`))
if errDefault != nil {
t.Fatalf("ParseConfigBytes() error = %v", errDefault)
}
if defaultCfg.Codex.ModelLevelCooling {
t.Fatalf("default ModelLevelCooling = true, want false")
}
}