(t *testing.T)
| 144 | } |
| 145 | |
| 146 | func 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 | |
| 181 | func TestContextExecuteDispatch_FullParity(t *testing.T) { |
| 182 | f := withFakeContextAdapter(t) |
nothing calls this directly
no test coverage detected