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

Function TestKnowledgePlugin_DescribeCall

cli/plugins/builtin_knowledge_test.go:174–202  ·  view source on GitHub ↗

TestKnowledgePlugin_DescribeCall pins the spinner-label contract: short, human one-liners — never the static description or the raw JSON envelope, both of which overflow a terminal row and flood the screen via the spinner's single-line repaint.

(t *testing.T)

Source from the content-addressed store, hash-verified

172// both of which overflow a terminal row and flood the screen via the
173// spinner's single-line repaint.
174func TestKnowledgePlugin_DescribeCall(t *testing.T) {
175 p := NewBuiltinKnowledgePlugin()
176 longQuery := strings.Repeat("kubernetes deployment strategy ", 10)
177
178 cases := []struct {
179 args []string
180 want string // substring expected in the label
181 }{
182 {[]string{`{"cmd":"search","args":{"query":"gateway env vars"}}`}, "gateway env vars"},
183 {[]string{`{"cmd":"get","args":{"source":"docs/install.md"}}`}, "docs/install.md"},
184 {[]string{`{"cmd":"toc","args":{"prefix":"docs/"}}`}, ""},
185 {[]string{`{"cmd":"list"}`}, ""},
186 {[]string{`not json`}, ""},
187 {[]string{`{"cmd":"search","args":{"query":"` + longQuery + `"}}`}, "…"},
188 }
189 for _, tc := range cases {
190 got := p.DescribeCall(tc.args)
191 if got == "" || got == p.Description() {
192 t.Errorf("DescribeCall(%q) must return a short dedicated label, got %q", tc.args, got)
193 continue
194 }
195 if len([]rune(got)) > 100 {
196 t.Errorf("label too long for a spinner row (%d runes): %q", len([]rune(got)), got)
197 }
198 if tc.want != "" && !strings.Contains(got, tc.want) {
199 t.Errorf("DescribeCall(%q) = %q, want substring %q", tc.args, got, tc.want)
200 }
201 }
202}

Callers

nothing calls this directly

Calls 4

DescribeCallMethod · 0.95
DescriptionMethod · 0.95
ErrorfMethod · 0.80

Tested by

no test coverage detected