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

Function TestKnowledgePlugin_Validation

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

Source from the content-addressed store, hash-verified

103}
104
105func TestKnowledgePlugin_Validation(t *testing.T) {
106 withFakeKnowledgeAdapter(t)
107 p := NewBuiltinKnowledgePlugin()
108
109 if _, err := p.Execute(context.Background(), []string{`{"cmd":"search","args":{}}`}); err == nil ||
110 !strings.Contains(err.Error(), `"query" is required`) {
111 t.Errorf("search without query must error, got %v", err)
112 }
113 if _, err := p.Execute(context.Background(), []string{`{"cmd":"get","args":{}}`}); err == nil ||
114 !strings.Contains(err.Error(), `"source" is required`) {
115 t.Errorf("get without source must error, got %v", err)
116 }
117 if _, err := p.Execute(context.Background(), []string{`{"cmd":"bogus"}`}); err == nil ||
118 !strings.Contains(err.Error(), "unknown cmd") {
119 t.Errorf("unknown cmd must error, got %v", err)
120 }
121 if _, err := p.Execute(context.Background(), nil); err == nil {
122 t.Error("empty args must error with an example")
123 }
124}
125
126func TestKnowledgePlugin_Metadata(t *testing.T) {
127 p := NewBuiltinKnowledgePlugin()

Callers

nothing calls this directly

Calls 5

ExecuteMethod · 0.95
withFakeKnowledgeAdapterFunction · 0.85
ErrorfMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected