TestEnsureHamrpassLazyCreates: with hamrpass hidden from config.yaml, EnsureHamrpass returns a profile from the canonical seed values, and is idempotent: twice returns the same pointer.
(t *testing.T)
| 200 | // EnsureHamrpass returns a profile from the canonical seed values, and is |
| 201 | // idempotent: twice returns the same pointer. |
| 202 | func TestEnsureHamrpassLazyCreates(t *testing.T) { |
| 203 | cfg := &Config{ |
| 204 | Active: "local", |
| 205 | Models: map[string]*Profile{ |
| 206 | "local": {LLM: "m", URL: "http://x", Key: "", ContextSize: 65536}, |
| 207 | }, |
| 208 | } |
| 209 | hp := cfg.EnsureHamrpass() |
| 210 | if hp == nil { |
| 211 | t.Fatal("EnsureHamrpass returned nil") |
| 212 | } |
| 213 | if hp.URL != "https://codehamr.com" || hp.LLM != "hamrpass" || hp.Key != "" { |
| 214 | t.Fatalf("lazy-created hamrpass has wrong fields: %+v", hp) |
| 215 | } |
| 216 | if got := cfg.Models["hamrpass"]; got != hp { |
| 217 | t.Fatal("EnsureHamrpass did not store the entry on cfg.Models") |
| 218 | } |
| 219 | hp2 := cfg.EnsureHamrpass() |
| 220 | if hp2 != hp { |
| 221 | t.Fatal("EnsureHamrpass should be idempotent: second call must return the same pointer") |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | // TestBootstrapPreservesExistingHamrpassKey: a user-supplied hamrpass key must |
| 226 | // round-trip untouched. Guards against any future "tidy on read" that would |
nothing calls this directly
no test coverage detected