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

Function TestBootstrapCoercesBogusContextSize

internal/config/config_test.go:552–577  ·  view source on GitHub ↗

TestBootstrapCoercesBogusContextSize: context_size 0 (or missing) is coerced to the default rather than degrading Pack() to "newest message only".

(t *testing.T)

Source from the content-addressed store, hash-verified

550// TestBootstrapCoercesBogusContextSize: context_size 0 (or missing) is coerced
551// to the default rather than degrading Pack() to "newest message only".
552func TestBootstrapCoercesBogusContextSize(t *testing.T) {
553 dir := t.TempDir()
554 cdir := filepath.Join(dir, DirName)
555 if err := os.MkdirAll(cdir, 0o755); err != nil {
556 t.Fatal(err)
557 }
558 yaml := []byte(`active: local
559models:
560 local:
561 llm: m
562 url: http://x
563 key: ""
564 context_size: 0
565`)
566 if err := os.WriteFile(filepath.Join(cdir, "config.yaml"), yaml, 0o644); err != nil {
567 t.Fatal(err)
568 }
569 cfg, _, err := Bootstrap(dir)
570 if err != nil {
571 t.Fatal(err)
572 }
573 if cfg.ActiveProfile().ContextSize != defaultContextSize {
574 t.Fatalf("context_size=0 should be coerced to %d, got %d",
575 defaultContextSize, cfg.ActiveProfile().ContextSize)
576 }
577}
578
579// TestBootstrapRejectsNilProfile: `models: { local: ~ }` decodes to a nil
580// *Profile the ContextSize coercion loop would deref-panic on. Bootstrap must

Callers

nothing calls this directly

Calls 2

BootstrapFunction · 0.85
ActiveProfileMethod · 0.80

Tested by

no test coverage detected