TestSetActivePersists: SetActive flips Active and writes config.yaml.
(t *testing.T)
| 408 | |
| 409 | // TestSetActivePersists: SetActive flips Active and writes config.yaml. |
| 410 | func TestSetActivePersists(t *testing.T) { |
| 411 | dir := t.TempDir() |
| 412 | cfg, _, err := Bootstrap(dir) |
| 413 | if err != nil { |
| 414 | t.Fatal(err) |
| 415 | } |
| 416 | // add a second profile so SetActive has somewhere to go |
| 417 | cfg.Models["other"] = &Profile{LLM: "m", URL: "http://x", ContextSize: 1} |
| 418 | if err := cfg.SetActive("other"); err != nil { |
| 419 | t.Fatal(err) |
| 420 | } |
| 421 | if cfg.Active != "other" { |
| 422 | t.Fatalf("Active = %q, want other", cfg.Active) |
| 423 | } |
| 424 | reloaded, _, err := Bootstrap(dir) |
| 425 | if err != nil { |
| 426 | t.Fatal(err) |
| 427 | } |
| 428 | if reloaded.Active != "other" { |
| 429 | t.Fatal("Active did not persist") |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | // TestSetActiveRejectsUnknown: SetActive returns an error for an unknown name. |
| 434 | func TestSetActiveRejectsUnknown(t *testing.T) { |