From 0e2580ea64fd5c0fb64a48a7a2ce7cc38ebb3b50 Mon Sep 17 00:00:00 2001 From: Thomas Beaudouin Date: Mon, 16 Feb 2026 14:20:58 +0800 Subject: [PATCH] test: add env override validation when config file is missing --- pkg/config/config_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 14618b109..d08e95d79 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -1,6 +1,7 @@ package config import ( + "path/filepath" "testing" ) @@ -13,6 +14,21 @@ func TestDefaultConfig_HeartbeatEnabled(t *testing.T) { } } +// TestLoadConfig_EnvOverridesWithoutFile ensures env vars are applied when the config file is missing. +func TestLoadConfig_EnvOverridesWithoutFile(t *testing.T) { + t.Setenv("PICOCLAW_AGENTS_DEFAULTS_MODEL", "env-model") + + missing := filepath.Join(t.TempDir(), "missing.json") + cfg, err := LoadConfig(missing) + if err != nil { + t.Fatalf("expected no error, got %v", err) + } + + if got := cfg.Agents.Defaults.Model; got != "env-model" { + t.Fatalf("expected model from env, got %q", got) + } +} + // TestDefaultConfig_WorkspacePath verifies workspace path is correctly set func TestDefaultConfig_WorkspacePath(t *testing.T) { cfg := DefaultConfig()