MCPcopy Index your code
hub / github.com/cli/cli / TestNewCmdCode

Function TestNewCmdCode

pkg/cmd/search/code/code_test.go:20–133  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func TestNewCmdCode(t *testing.T) {
21 tests := []struct {
22 name string
23 input string
24 output CodeOptions
25 wantErr bool
26 errMsg string
27 }{
28 {
29 name: "no arguments",
30 input: "",
31 wantErr: true,
32 errMsg: "specify search keywords or flags",
33 },
34 {
35 name: "keyword arguments",
36 input: "react lifecycle",
37 output: CodeOptions{
38 Query: search.Query{
39 Keywords: []string{"react", "lifecycle"},
40 Kind: "code",
41 Limit: 30,
42 },
43 },
44 },
45 {
46 name: "web flag",
47 input: "--web",
48 output: CodeOptions{
49 Query: search.Query{
50 Keywords: []string{},
51 Kind: "code",
52 Limit: 30,
53 },
54 WebMode: true,
55 },
56 },
57 {
58 name: "limit flag",
59 input: "--limit 10",
60 output: CodeOptions{
61 Query: search.Query{
62 Keywords: []string{},
63 Kind: "code",
64 Limit: 10,
65 },
66 },
67 },
68 {
69 name: "invalid limit flag",
70 input: "--limit 1001",
71 wantErr: true,
72 errMsg: "`--limit` must be between 1 and 1000",
73 },
74 {
75 name: "qualifier flags",
76 input: `
77 --extension=extension

Callers

nothing calls this directly

Calls 4

TestFunction · 0.92
NewCmdCodeFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected