From 420b5aebf888c638ac096e1476c06eac979ac257 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 3 Oct 2025 23:50:49 +0300 Subject: Switch inline prompt markers to >! prefix --- internal/hexaicli/run_test.go | 12 ++++++++++-- internal/hexaicli/testhelpers_test.go | 10 ++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'internal/hexaicli') diff --git a/internal/hexaicli/run_test.go b/internal/hexaicli/run_test.go index dfde068..991965e 100644 --- a/internal/hexaicli/run_test.go +++ b/internal/hexaicli/run_test.go @@ -125,12 +125,20 @@ func TestRunWithClient_ErrorPrint(t *testing.T) { func TestRun_OpenAI_NoKey_ShowsError(t *testing.T) { dir := testingTempDir(t) - // write config with provider=openai - writeTOML(t, filepath.Join(dir, "hexai", "config.toml"), map[string]string{"provider": "openai", "openai_model": "gpt-x"}) + // write config with provider=openai using sectioned tables + configPath := filepath.Join(dir, "hexai", "config.toml") + writeConfigString(t, configPath, ` +[provider] +name = "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", "") t.Setenv("OPENAI_API_KEY", "") + t.Setenv("HEXAI_PROVIDER", "") var out, errb bytes.Buffer // Run expects parsed flags; here args irrelevant err := Run(context.Background(), []string{"hello"}, strings.NewReader(""), &out, &errb) diff --git a/internal/hexaicli/testhelpers_test.go b/internal/hexaicli/testhelpers_test.go index 93f1e3d..4cc04f7 100644 --- a/internal/hexaicli/testhelpers_test.go +++ b/internal/hexaicli/testhelpers_test.go @@ -79,4 +79,14 @@ func writeTOML(t *testing.T, path string, m map[string]string) { } } +func writeConfigString(t *testing.T, path string, contents string) { + t.Helper() + if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { + t.Fatalf("mkdir: %v", err) + } + if err := os.WriteFile(path, []byte(contents), 0o644); err != nil { + t.Fatalf("write: %v", err) + } +} + func testingTempDir(t *testing.T) string { t.Helper(); return t.TempDir() } -- cgit v1.2.3