diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-06 11:14:27 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-06 11:14:27 +0300 |
| commit | fb267966f7840df222338f57023273a993a73c9a (patch) | |
| tree | d10066412f08b386a6f9fe9289f27124c6ebe9d6 /internal/hexaicli | |
| parent | 1bf4251a7edbd00902f22db77031d0f998569614 (diff) | |
use TOML not JSON for configuration
Diffstat (limited to 'internal/hexaicli')
| -rw-r--r-- | internal/hexaicli/run_test.go | 2 | ||||
| -rw-r--r-- | internal/hexaicli/testhelpers_test.go | 11 |
2 files changed, 7 insertions, 6 deletions
diff --git a/internal/hexaicli/run_test.go b/internal/hexaicli/run_test.go index 77daa8b..d192850 100644 --- a/internal/hexaicli/run_test.go +++ b/internal/hexaicli/run_test.go @@ -107,7 +107,7 @@ func TestRunWithClient_ErrorPrint(t *testing.T) { func TestRun_OpenAI_NoKey_ShowsError(t *testing.T) { dir := testingTempDir(t) // write config with provider=openai - writeJSON(t, filepath.Join(dir, "hexai", "config.json"), map[string]any{"provider": "openai", "openai_model": "gpt-x"}) + writeTOML(t, filepath.Join(dir, "hexai", "config.toml"), map[string]string{"provider": "openai", "openai_model": "gpt-x"}) t.Setenv("XDG_CONFIG_HOME", dir) // Ensure no OpenAI API key is present in environment t.Setenv("HEXAI_OPENAI_API_KEY", "") diff --git a/internal/hexaicli/testhelpers_test.go b/internal/hexaicli/testhelpers_test.go index 512a3ba..93f1e3d 100644 --- a/internal/hexaicli/testhelpers_test.go +++ b/internal/hexaicli/testhelpers_test.go @@ -3,7 +3,6 @@ package hexaicli import ( "context" - "encoding/json" "os" "path/filepath" "testing" @@ -62,8 +61,8 @@ func (s *fakeStreamer) ChatStream(ctx context.Context, messages []llm.Message, o return nil } -// small JSON writer for tests -func writeJSON(t *testing.T, path string, v any) { +// small TOML writer for tests (string values only) +func writeTOML(t *testing.T, path string, m map[string]string) { t.Helper() if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { t.Fatalf("mkdir: %v", err) @@ -73,8 +72,10 @@ func writeJSON(t *testing.T, path string, v any) { t.Fatalf("create: %v", err) } defer f.Close() - if err := json.NewEncoder(f).Encode(v); err != nil { - t.Fatalf("encode: %v", err) + for k, v := range m { + if _, err := f.WriteString(k + " = \"" + v + "\"\n"); err != nil { + t.Fatalf("write: %v", err) + } } } |
