(t *testing.T)
| 77 | } |
| 78 | |
| 79 | func 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 | |
| 101 | func TestCmdExampleParseRefsFiltersPlaceholdersAndProse(t *testing.T) { |
| 102 | // A line whose first word is prose yields no command at all. |
nothing calls this directly
no test coverage detected