@@ -8,16 +8,7 @@ import (
88 "testing"
99 )
1010
11-func TestDefaultConfig(t *testing.T) {
12- cfg := DefaultConfig()
13-
14- if cfg.Swarm.MaxMyses != 16 {
15- t.Errorf("expected max_myses=16, got %d", cfg.Swarm.MaxMyses)
16- }
17- if _, ok := cfg.Providers["ollama"]; !ok {
18- t.Error("expected ollama provider in defaults")
19- }
20-}
11+// TestDefaultConfig removed - config file is now required
2112
2213 func TestLoadFromFile(t *testing.T) {
2314 // Create temp config file
@@ -31,6 +22,9 @@ max_myses = 32
3122 [providers.ollama]
3223 endpoint = "http://custom:11434"
3324 model = "mistral"
25+temperature = 0.7
26+rate_limit = 2.0
27+rate_burst = 3
3428
3529 [mcp]
3630 upstream = "https://custom.mcp/endpoint"
@@ -60,10 +54,15 @@ func TestLoadWithTemperature(t *testing.T) {
6054 configPath := filepath.Join(tmpDir, "config.toml")
6155
6256 content := `
57+[swarm]
58+max_myses = 16
59+
6360 [providers.ollama]
6461 endpoint = "http://localhost:11434"
6562 model = "qwen3:4b"
6663 temperature = 0.5
64+rate_limit = 2.0
65+rate_burst = 3
6766 `
6867 if err := os.WriteFile(configPath, []byte(content), 0644); err != nil {
6968 t.Fatalf("failed to write test config: %v", err)
@@ -84,9 +83,13 @@ func TestLoadWithRateLimit(t *testing.T) {
8483 configPath := filepath.Join(tmpDir, "config.toml")
8584
8685 content := `
86+[swarm]
87+max_myses = 16
88+
8789 [providers.ollama]
8890 endpoint = "http://localhost:11434"
8991 model = "qwen3:4b"
92+temperature = 0.7
9093 rate_limit = 3.5
9194 rate_burst = 4
9295 `
@@ -156,6 +159,27 @@ model = ""
156159 }
157160
158161 func TestLoadWithEnvOverrides(t *testing.T) {
162+ tmpDir := t.TempDir()
163+ configPath := filepath.Join(tmpDir, "config.toml")
164+
165+ content := `
166+[swarm]
167+max_myses = 16
168+
169+[providers.ollama]
170+endpoint = "http://localhost:11434"
171+model = "qwen3:4b"
172+temperature = 0.7
173+rate_limit = 2.0
174+rate_burst = 3
175+
176+[mcp]
177+upstream = "https://default.mcp/endpoint"
178+`
179+ if err := os.WriteFile(configPath, []byte(content), 0644); err != nil {
180+ t.Fatalf("failed to write test config: %v", err)
181+ }
182+
159183 // Set env vars
160184 os.Setenv("ZOEA_MAX_MYSES", "10")
161185 os.Setenv("ZOEA_MCP_ENDPOINT", "https://env.mcp/endpoint")
@@ -164,7 +188,7 @@ func TestLoadWithEnvOverrides(t *testing.T) {
164188 os.Unsetenv("ZOEA_MCP_ENDPOINT")
165189 }()
166190
167- cfg, err := Load("")
191+ cfg, err := Load(configPath)
168192 if err != nil {
169193 t.Fatalf("Load() error: %v", err)
170194 }
@@ -178,14 +202,12 @@ func TestLoadWithEnvOverrides(t *testing.T) {
178202 }
179203
180204 func TestLoadNonExistentFile(t *testing.T) {
181- cfg, err := Load("/nonexistent/path/config.toml")
182- if err != nil {
183- t.Fatalf("Load() should not error for non-existent file: %v", err)
205+ _, err := Load("/nonexistent/path/config.toml")
206+ if err == nil {
207+ t.Fatal("Load() should error for non-existent file")
184208 }
185-
186- // Should return defaults
187- if cfg.Swarm.MaxMyses != 16 {
188- t.Errorf("expected max_myses=16, got %d", cfg.Swarm.MaxMyses)
209+ if !strings.Contains(err.Error(), "config file not found") {
210+ t.Errorf("expected 'config file not found' error, got %v", err)
189211 }
190212 }
191213
@@ -261,9 +283,15 @@ func TestLoadEnvOverridePrecedence(t *testing.T) {
261283 configPath := filepath.Join(tmpDir, "config.toml")
262284
263285 content := `
286+[swarm]
287+max_myses = 16
288+
264289 [providers.ollama]
265290 endpoint = "http://file-endpoint"
266291 model = "file-model"
292+temperature = 0.7
293+rate_limit = 2.0
294+rate_burst = 3
267295 `
268296 if err := os.WriteFile(configPath, []byte(content), 0644); err != nil {
269297 t.Fatalf("failed to write test config: %v", err)
@@ -290,7 +318,23 @@ model = "file-model"
290318 }
291319
292320 func TestLoadIgnoresInvalidEnvOverrides(t *testing.T) {
293- defaults := DefaultConfig()
321+ tmpDir := t.TempDir()
322+ configPath := filepath.Join(tmpDir, "config.toml")
323+
324+ content := `
325+[swarm]
326+max_myses = 16
327+
328+[providers.ollama]
329+endpoint = "http://localhost:11434"
330+model = "qwen3:4b"
331+temperature = 0.7
332+rate_limit = 2.0
333+rate_burst = 3
334+`
335+ if err := os.WriteFile(configPath, []byte(content), 0644); err != nil {
336+ t.Fatalf("failed to write test config: %v", err)
337+ }
294338
295339 os.Setenv("ZOEA_MAX_MYSES", "not-a-number")
296340 os.Setenv("ZOEA_OLLAMA_TEMPERATURE", "bad")
@@ -303,22 +347,23 @@ func TestLoadIgnoresInvalidEnvOverrides(t *testing.T) {
303347 os.Unsetenv("ZOEA_OLLAMA_RATE_BURST")
304348 }()
305349
306- cfg, err := Load("")
350+ cfg, err := Load(configPath)
307351 if err != nil {
308352 t.Fatalf("Load() error: %v", err)
309353 }
310354
311- if cfg.Swarm.MaxMyses != defaults.Swarm.MaxMyses {
312- t.Errorf("expected max_myses=%d, got %d", defaults.Swarm.MaxMyses, cfg.Swarm.MaxMyses)
355+ // Invalid env overrides should be ignored, file values should remain
356+ if cfg.Swarm.MaxMyses != 16 {
357+ t.Errorf("expected max_myses=16, got %d", cfg.Swarm.MaxMyses)
313358 }
314- if cfg.Providers["ollama"].Temperature != defaults.Providers["ollama"].Temperature {
315- t.Errorf("expected temperature=%v, got %v", defaults.Providers["ollama"].Temperature, cfg.Providers["ollama"].Temperature)
359+ if cfg.Providers["ollama"].Temperature != 0.7 {
360+ t.Errorf("expected temperature=0.7, got %v", cfg.Providers["ollama"].Temperature)
316361 }
317- if cfg.Providers["ollama"].RateLimit != defaults.Providers["ollama"].RateLimit {
318- t.Errorf("expected rate_limit=%v, got %v", defaults.Providers["ollama"].RateLimit, cfg.Providers["ollama"].RateLimit)
362+ if cfg.Providers["ollama"].RateLimit != 2.0 {
363+ t.Errorf("expected rate_limit=2.0, got %v", cfg.Providers["ollama"].RateLimit)
319364 }
320- if cfg.Providers["ollama"].RateBurst != defaults.Providers["ollama"].RateBurst {
321- t.Errorf("expected rate_burst=%d, got %d", defaults.Providers["ollama"].RateBurst, cfg.Providers["ollama"].RateBurst)
365+ if cfg.Providers["ollama"].RateBurst != 3 {
366+ t.Errorf("expected rate_burst=3, got %d", cfg.Providers["ollama"].RateBurst)
322367 }
323368 }
324369
@@ -511,6 +556,9 @@ default_model = "qwen3:8b"
511556 [providers.ollama]
512557 endpoint = "http://localhost:11434"
513558 model = "qwen3:8b"
559+temperature = 0.7
560+rate_limit = 2.0
561+rate_burst = 3
514562 `
515563 if err := os.WriteFile(configPath, []byte(configContent), 0644); err != nil {
516564 t.Fatalf("failed to write test config: %v", err)