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

Function TestContextExecuteDispatch

cli/plugins/builtin_context_test.go:146–179  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

144}
145
146func TestContextExecuteDispatch(t *testing.T) {
147 f := withFakeContextAdapter(t)
148 p := NewBuiltinContextPlugin()
149 run := func(payload string) (string, error) {
150 return p.Execute(context.Background(), []string{payload})
151 }
152
153 if _, err := run(`{"cmd":"create","args":{"name":"react","paths":["/tmp/r.jsonl"],"mode":"knowledge","force":true}}`); err != nil {
154 t.Fatal(err)
155 }
156 if f.createName != "react" || f.createMode != "knowledge" || !f.createForce || strings.Join(f.createPaths, ",") != "/tmp/r.jsonl" {
157 t.Fatalf("create routed wrong: %+v", f)
158 }
159
160 if _, err := run(`{"cmd":"attach","args":{"name":"react","rag":8,"priority":5}}`); err != nil {
161 t.Fatal(err)
162 }
163 if f.attachName != "react" || f.attachRag != 8 || f.attachPriority != 5 {
164 t.Fatalf("attach routed wrong: %+v", f)
165 }
166
167 if _, err := run(`{"cmd":"detach","args":{"name":"react"}}`); err != nil || f.detachName != "react" {
168 t.Fatalf("detach routed wrong: %v %q", err, f.detachName)
169 }
170 if _, err := run(`{"cmd":"delete","args":{"name":"react"}}`); err != nil || f.deleteName != "react" {
171 t.Fatalf("delete routed wrong: %v %q", err, f.deleteName)
172 }
173 if _, err := run(`{"cmd":"list"}`); err != nil || !f.listed {
174 t.Fatalf("list routed wrong: %v", err)
175 }
176 if _, err := run(`{"cmd":"status"}`); err != nil || !f.statused {
177 t.Fatalf("status routed wrong: %v", err)
178 }
179}
180
181func TestContextExecuteDispatch_FullParity(t *testing.T) {
182 f := withFakeContextAdapter(t)

Callers

nothing calls this directly

Calls 4

ExecuteMethod · 0.95
withFakeContextAdapterFunction · 0.85
NewBuiltinContextPluginFunction · 0.85
runFunction · 0.50

Tested by

no test coverage detected