MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestBootstrapLoadsMultipleProfiles

Function TestBootstrapLoadsMultipleProfiles

internal/config/config_test.go:261–303  ·  view source on GitHub ↗

TestBootstrapLoadsMultipleProfiles: a two-profile config round-trips and Bootstrap picks the declared `active`.

(t *testing.T)

Source from the content-addressed store, hash-verified

259// TestBootstrapLoadsMultipleProfiles: a two-profile config round-trips and
260// Bootstrap picks the declared `active`.
261func TestBootstrapLoadsMultipleProfiles(t *testing.T) {
262 dir := t.TempDir()
263 cdir := filepath.Join(dir, DirName)
264 if err := os.MkdirAll(cdir, 0o755); err != nil {
265 t.Fatal(err)
266 }
267 yaml := []byte(`active: work
268models:
269 home:
270 llm: local-model
271 url: http://llm:11434
272 key: ""
273 context_size: 65536
274 work:
275 llm: cloud-model
276 url: https://api.example/v1
277 key: sk-abc
278 context_size: 200000
279`)
280 if err := os.WriteFile(filepath.Join(cdir, "config.yaml"), yaml, 0o644); err != nil {
281 t.Fatal(err)
282 }
283 cfg, _, err := Bootstrap(dir)
284 if err != nil {
285 t.Fatal(err)
286 }
287 if cfg.Active != "work" {
288 t.Fatalf("Active = %q, want work", cfg.Active)
289 }
290 // Bootstrap must not inject local/hamrpass on top of the declared profiles.
291 if len(cfg.Models) != 2 {
292 t.Fatalf("expected exactly the two declared profiles, got %d: %+v", len(cfg.Models), cfg.Models)
293 }
294 for _, name := range []string{"home", "work"} {
295 if _, ok := cfg.Models[name]; !ok {
296 t.Fatalf("expected profile %q in loaded config", name)
297 }
298 }
299 p := cfg.ActiveProfile()
300 if p.LLM != "cloud-model" || p.URL != "https://api.example/v1" || p.Key != "sk-abc" {
301 t.Fatalf("active profile wrong: %+v", p)
302 }
303}
304
305// TestConfigFilePermissionsAreOwnerOnly is the regression for a world-readable
306// hamrpass key: /hamrpass stores the bearer token in plaintext, so any local

Callers

nothing calls this directly

Calls 2

BootstrapFunction · 0.85
ActiveProfileMethod · 0.80

Tested by

no test coverage detected