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

Function TestExtractStringArg_AllShapes

cli/plugins/args_extract_test.go:20–121  ·  view source on GitHub ↗

TestExtractStringArg_AllShapes is the regression matrix for the args extractor used by every plugin's DescribeCall. The original coverage of extractStringArg sat at 25 percent because only the JSON-envelope path was exercised by the websearch tests. This matrix pins all branches: empty, flag-style,

(t *testing.T)

Source from the content-addressed store, hash-verified

18// path was exercised by the websearch tests. This matrix pins all
19// branches: empty, flag-style, positional-fallback, multi-key fallback.
20func TestExtractStringArg_AllShapes(t *testing.T) {
21 cases := []struct {
22 name string
23 args []string
24 keys []string
25 want string
26 }{
27 {
28 name: "empty args returns empty",
29 args: nil,
30 keys: []string{"query"},
31 want: "",
32 },
33 {
34 name: "flat JSON top-level match",
35 args: []string{`{"query":"golang errgroup"}`},
36 keys: []string{"query"},
37 want: "golang errgroup",
38 },
39 {
40 name: "nested @coder envelope match",
41 args: []string{`{"cmd":"search","args":{"query":"login"}}`},
42 keys: []string{"query"},
43 want: "login",
44 },
45 {
46 name: "first key in keys list wins",
47 args: []string{`{"q":"second","query":"first"}`},
48 keys: []string{"query", "q"},
49 want: "first",
50 },
51 {
52 name: "second key is fallback when first missing",
53 args: []string{`{"q":"fallback"}`},
54 keys: []string{"query", "q"},
55 want: "fallback",
56 },
57 {
58 name: "flag style --key value",
59 args: []string{"search", "--query", "kubernetes basics"},
60 keys: []string{"query"},
61 want: "kubernetes basics",
62 },
63 {
64 name: "flag style --key=value",
65 args: []string{"--query=golang"},
66 keys: []string{"query"},
67 want: "golang",
68 },
69 {
70 name: "double-quoted flag value",
71 args: []string{"--query", `"quoted value"`},
72 keys: []string{"query"},
73 want: "quoted value",
74 },
75 {
76 name: "single-quoted flag value",
77 args: []string{"--query", "'single quoted'"},

Callers

nothing calls this directly

Calls 3

extractStringArgFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected