返回 DeepSeek-Reasonix
offline_provider_test.go
根目录 / internal / cli / offline_provider_test.go
1 package cli
2
3 import (
4 "os"
5 "path/filepath"
6 "testing"
7
8 "reasonix/internal/config"
9 )
10
11 // pinProviderOffline points the isolated home at a provider that can never be
12 // reached, so a run under test fails at setup instead of dialling a real API.
13 // Without it the default config targets api.deepseek.com and the assertion
14 // silently depends on how that host rejects an unauthenticated call.
15 func pinProviderOffline(t *testing.T) {
16 t.Helper()
17 path := config.UserConfigPath()
18 if path == "" {
19 t.Fatal("UserConfigPath() is empty under an isolated home")
20 }
21 if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
22 t.Fatal(err)
23 }
24 body := `default_model = "offline-test/model-a"
25
26 [[providers]]
27 name = "offline-test"
28 kind = "openai"
29 base_url = "https://reasonix-tests.invalid/v1"
30 models = ["model-a"]
31 default = "model-a"
32 api_key_env = "REASONIX_TEST_ABSENT_KEY"
33 `
34 if err := os.WriteFile(path, []byte(body), 0o600); err != nil {
35 t.Fatal(err)
36 }
37 }
38
38 lines GO