MCPcopy Index your code
hub / github.com/larksuite/cli / TestCmdExampleParseRefsExtractsCommands

Function TestCmdExampleParseRefsExtractsCommands

cmd/cmdexample_units_test.go:79–99  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

77}
78
79func TestCmdExampleParseRefsExtractsCommands(t *testing.T) {
80 content := strings.Join([]string{
81 "运行 `lark-cli contact +search-user --query 张三` 搜索", // inline code
82 "```bash",
83 "lark-cli api GET /open-apis/x --params '{}'", // bash block
84 "```",
85 "用 lark-cli mail user_mailbox.messages batch_modify 即可", // bare prose command
86 "npx foo | lark-cli api GET /y", // after a pipe
87 }, "\n")
88 refs := parseRefs(content)
89 if len(refs) != 4 {
90 t.Fatalf("expected 4 refs, got %d: %v", len(refs), refWordsOf(refs))
91 }
92 if got := refs[0]; strings.Join(got.words, " ") != "contact +search-user" ||
93 len(got.flags) != 1 || got.flags[0] != "--query" {
94 t.Errorf("ref0 = %+v", got)
95 }
96 if got := refs[1]; strings.Join(got.words, " ") != "api GET /open-apis/x" {
97 t.Errorf("ref1 words = %v", got.words)
98 }
99}
100
101func TestCmdExampleParseRefsFiltersPlaceholdersAndProse(t *testing.T) {
102 // A line whose first word is prose yields no command at all.

Callers

nothing calls this directly

Calls 2

parseRefsFunction · 0.85
refWordsOfFunction · 0.85

Tested by

no test coverage detected