MCPcopy Create free account
hub / github.com/diillson/chatcli / TestKnowledgePlugin_Metadata

Function TestKnowledgePlugin_Metadata

cli/plugins/builtin_knowledge_test.go:126–152  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

124}
125
126func TestKnowledgePlugin_Metadata(t *testing.T) {
127 p := NewBuiltinKnowledgePlugin()
128 if p.Name() != "@knowledge" || p.Version() == "" || p.Path() != "" {
129 t.Errorf("metadata: name=%q version=%q path=%q", p.Name(), p.Version(), p.Path())
130 }
131 if d := p.Description(); !strings.Contains(d, "knowledge bases") {
132 t.Errorf("Description = %q", d)
133 }
134 if u := p.Usage(); !strings.Contains(u, `"cmd":"search"`) {
135 t.Errorf("Usage must show the envelope example, got %q", u)
136 }
137 var schema struct {
138 Subcommands []struct {
139 Name string `json:"name"`
140 } `json:"subcommands"`
141 }
142 if err := json.Unmarshal([]byte(p.Schema()), &schema); err != nil {
143 t.Fatalf("Schema is not valid JSON: %v", err)
144 }
145 got := make([]string, 0, len(schema.Subcommands))
146 for _, s := range schema.Subcommands {
147 got = append(got, s.Name)
148 }
149 if strings.Join(got, ",") != "search,get,toc,list" {
150 t.Errorf("Schema subcommands = %v", got)
151 }
152}
153
154func TestKnowledgePlugin_NoAdapter(t *testing.T) {
155 SetKnowledgeAdapter(nil)

Callers

nothing calls this directly

Calls 8

NameMethod · 0.95
VersionMethod · 0.95
PathMethod · 0.95
DescriptionMethod · 0.95
UsageMethod · 0.95
SchemaMethod · 0.95
ErrorfMethod · 0.80

Tested by

no test coverage detected