package modelcontext import ( "strings" "testing" ) func TestAnnotateSearchNotes(t *testing.T) { t.Parallel() base := "\n" got := annotateSearchNotes(base, map[string]interface{}{ "omitted_for_budget": 4, "partial_failures": []string{"[kb-2]: vector store unavailable"}, }) if !strings.Contains(got, ``) || !strings.Contains(got, "[kb-2]: vector store unavailable") || !strings.HasSuffix(got, "") { t.Fatalf("annotated = %q", got) } if annotateSearchNotes(base, map[string]interface{}{}) != base { t.Fatal("nothing to add must leave the output unchanged") } } func TestAnnotateGraphResult(t *testing.T) { t.Parallel() base := "\n" got := annotateGraphResult(base, map[string]interface{}{ "relations": []map[string]interface{}{{"source": "Kubernetes", "type": "orchestrates", "target": "Docker"}}, "errors": []string{"KB b2: graph extraction not configured"}, }) for _, want := range []string{ ``, "KB b2: graph extraction not configured", } { if !strings.Contains(got, want) { t.Fatalf("missing %q in %q", want, got) } } if annotateGraphResult(base, map[string]interface{}{}) != base { t.Fatal("nothing to add must leave the output unchanged") } } func TestMatchAddsToContent(t *testing.T) { t.Parallel() content := "Install the engine, then configure psionic drive parameters." if matchAddsToContent("... configure psionic drive ...", content) { t.Fatal("an excerpt of the content adds nothing") } if !matchAddsToContent("How do I tune the drive?", content) { t.Fatal("a matched question absent from the content adds information") } if !matchAddsToContent("anything", "") { t.Fatal("a snippet-only row keeps its snippet") } }