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)
| 172 | // both of which overflow a terminal row and flood the screen via the |
| 173 | // spinner's single-line repaint. |
| 174 | func 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 | } |
nothing calls this directly
no test coverage detected