summaryrefslogtreecommitdiff
path: root/internal/appconfig/config_alias_test.go
blob: 6cc5bdac704078dc25fb4869570ad8f2cf961dc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package appconfig

import (
    "log"
    "os"
    "path/filepath"
    "testing"
)

func TestOpenAIPresets_AliasResolution(t *testing.T) {
    dir := t.TempDir()
    t.Setenv("XDG_CONFIG_HOME", dir)
    cfgDir := filepath.Join(dir, "hexai")
    if err := os.MkdirAll(cfgDir, 0o755); err != nil {
        t.Fatalf("mkdir: %v", err)
    }
    toml := `
[provider]
name = "openai"

[openai]
model = "codex"

[openai.presets]
codex = "gpt-5-codex"
`
    path := filepath.Join(cfgDir, "config.toml")
    if err := os.WriteFile(path, []byte(toml), 0o644); err != nil {
        t.Fatalf("write: %v", err)
    }
    cfg := Load(log.New(os.Stderr, "test ", 0))
    if cfg.OpenAIModel != "gpt-5-codex" {
        t.Fatalf("expected alias to resolve to gpt-5-codex, got %q", cfg.OpenAIModel)
    }
}