diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-08 21:03:50 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-08 21:03:50 +0000 |
| commit | 632ea5a44731af94b6238f330a3b5440906c8ae7 (patch) | |
| tree | d8c780412598d66b89ef390b5729e379fdfd9d5b /internal/config | |
| parent | 406247b14985ab57902e8e42898dc8cb8960290d (diff) | |
| parent | 93a4c852bf726b00e8014d385165f847763fa214 (diff) | |
merge: pull latest from master and resolve conflicts
- Resolve conflicts in API server, CLI, and executor.
- Maintain Gemini classification and assignment logic.
- Update UI to use generic agent config and project_dir.
- Fix ProjectDir/WorkingDir inconsistencies in Gemini runner.
- All tests passing after merge.
Diffstat (limited to 'internal/config')
| -rw-r--r-- | internal/config/config.go | 14 | ||||
| -rw-r--r-- | internal/config/config_test.go | 24 |
2 files changed, 35 insertions, 3 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index a66524a..d3d9d68 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,6 +1,8 @@ package config import ( + "errors" + "fmt" "os" "path/filepath" ) @@ -17,8 +19,14 @@ type Config struct { WebhookURL string `toml:"webhook_url"` } -func Default() *Config { - home, _ := os.UserHomeDir() +func Default() (*Config, error) { + home, err := os.UserHomeDir() + if err != nil { + return nil, fmt.Errorf("cannot determine home directory: %w", err) + } + if home == "" { + return nil, errors.New("cannot determine home directory: HOME is empty") + } dataDir := filepath.Join(home, ".claudomator") return &Config{ DataDir: dataDir, @@ -29,7 +37,7 @@ func Default() *Config { MaxConcurrent: 3, DefaultTimeout: "15m", ServerAddr: ":8484", - } + }, nil } // EnsureDirs creates the data directory structure. diff --git a/internal/config/config_test.go b/internal/config/config_test.go new file mode 100644 index 0000000..766b856 --- /dev/null +++ b/internal/config/config_test.go @@ -0,0 +1,24 @@ +package config + +import ( + "testing" +) + +func TestDefault_EmptyHome_ReturnsError(t *testing.T) { + t.Setenv("HOME", "") + _, err := Default() + if err == nil { + t.Fatal("expected error when HOME is empty, got nil") + } +} + +func TestDefault_ValidHome_ReturnsConfig(t *testing.T) { + t.Setenv("HOME", "/tmp/testhome") + cfg, err := Default() + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if cfg.DataDir != "/tmp/testhome/.claudomator" { + t.Errorf("DataDir = %q, want /tmp/testhome/.claudomator", cfg.DataDir) + } +} |
