summaryrefslogtreecommitdiff
path: root/internal/config/config_test.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-05-20 19:23:45 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-05-20 19:23:45 +0000
commit4bef835671542d5785c7dc6229662b9d5b0053f8 (patch)
tree1645363944f59831d249f1dc4d14c4be0e1f712d /internal/config/config_test.go
parentbf5ea107f6aec57c1fc3d094cd42aef239d46f15 (diff)
feat: add [runners] config section to toggle each runner on/off
Adds RunnersConfig{Claude,Gemini,Local,Container *bool} to Config, parsed from a [runners] TOML section. Each field uses the *bool pointer pattern (nil = enabled by default, false = disabled) so existing installs require no config changes. serve.go / run.go now gate each runner registration on the corresponding Enabled() method. The pool's runners map remains the authoritative routing table — absent entries are already skipped by pickAgent and fail-fast in getRunner, so no executor changes are needed. Example: [runners] gemini = false # disable cloud gemini runner local = true # explicit (same as default) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/config/config_test.go')
-rw-r--r--internal/config/config_test.go82
1 files changed, 82 insertions, 0 deletions
diff --git a/internal/config/config_test.go b/internal/config/config_test.go
index e4f1a5d..0d47ca0 100644
--- a/internal/config/config_test.go
+++ b/internal/config/config_test.go
@@ -54,6 +54,88 @@ func TestLoadFile_MissingFile_ReturnsError(t *testing.T) {
}
}
+func TestRunnersConfig_DefaultsAllEnabled(t *testing.T) {
+ r := RunnersConfig{}
+ if !r.ClaudeEnabled() {
+ t.Error("claude should be enabled by default (nil)")
+ }
+ if !r.GeminiEnabled() {
+ t.Error("gemini should be enabled by default (nil)")
+ }
+ if !r.LocalEnabled() {
+ t.Error("local should be enabled by default (nil)")
+ }
+ if !r.ContainerEnabled() {
+ t.Error("container should be enabled by default (nil)")
+ }
+}
+
+func TestRunnersConfig_ExplicitFalseDisables(t *testing.T) {
+ f := false
+ r := RunnersConfig{Claude: &f, Gemini: &f, Local: &f, Container: &f}
+ if r.ClaudeEnabled() {
+ t.Error("explicit false should disable claude")
+ }
+ if r.GeminiEnabled() {
+ t.Error("explicit false should disable gemini")
+ }
+ if r.LocalEnabled() {
+ t.Error("explicit false should disable local")
+ }
+ if r.ContainerEnabled() {
+ t.Error("explicit false should disable container")
+ }
+}
+
+func TestRunnersConfig_ExplicitTrueEnables(t *testing.T) {
+ tr := true
+ r := RunnersConfig{Claude: &tr, Gemini: &tr, Local: &tr, Container: &tr}
+ if !r.ClaudeEnabled() || !r.GeminiEnabled() || !r.LocalEnabled() || !r.ContainerEnabled() {
+ t.Error("explicit true should keep all runners enabled")
+ }
+}
+
+func TestRunnersConfig_MixedToggles(t *testing.T) {
+ f, tr := false, true
+ r := RunnersConfig{Claude: &tr, Gemini: &f, Local: &tr}
+ if !r.ClaudeEnabled() {
+ t.Error("claude should be enabled")
+ }
+ if r.GeminiEnabled() {
+ t.Error("gemini should be disabled")
+ }
+ if !r.LocalEnabled() {
+ t.Error("local should be enabled")
+ }
+ if !r.ContainerEnabled() {
+ t.Error("container should be enabled (nil = default)")
+ }
+}
+
+func TestRunnersConfig_TOMLRoundTrip(t *testing.T) {
+ dir := t.TempDir()
+ path := filepath.Join(dir, "config.toml")
+ toml := "[runners]\ngemini = false\n"
+ if err := os.WriteFile(path, []byte(toml), 0600); err != nil {
+ t.Fatal(err)
+ }
+ t.Setenv("HOME", dir)
+
+ cfg, err := LoadFile(path)
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+ if cfg.Runners.GeminiEnabled() {
+ t.Error("gemini should be disabled after TOML load")
+ }
+ if !cfg.Runners.ClaudeEnabled() {
+ t.Error("claude should remain enabled (not in TOML)")
+ }
+ if !cfg.Runners.LocalEnabled() {
+ t.Error("local should remain enabled (not in TOML)")
+ }
+}
+
func TestLocalModel_UseForElaborate_EmptyEndpoint(t *testing.T) {
m := LocalModel{}
if m.UseForElaborate() {