MCPcopy
hub / github.com/cli/cli / TestCodeRun

Function TestCodeRun

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

Source from the content-addressed store, hash-verified

133}
134
135func TestCodeRun(t *testing.T) {
136 var query = search.Query{
137 Keywords: []string{"map"},
138 Kind: "code",
139 Limit: 30,
140 Qualifiers: search.Qualifiers{
141 Language: "go",
142 Repo: []string{"cli/cli"},
143 },
144 }
145 tests := []struct {
146 errMsg string
147 name string
148 opts *CodeOptions
149 tty bool
150 wantErr bool
151 wantStderr string
152 wantStdout string
153 wantBrowse string
154 }{
155 {
156 name: "displays results tty",
157 opts: &CodeOptions{
158 Query: query,
159 Searcher: &search.SearcherMock{
160 CodeFunc: func(query search.Query) (search.CodeResult, error) {
161 return search.CodeResult{
162 IncompleteResults: false,
163 Items: []search.Code{
164 {
165 Name: "context.go",
166 Path: "context/context.go",
167 Repository: search.Repository{
168 FullName: "cli/cli",
169 },
170 TextMatches: []search.TextMatch{
171 {
172 Fragment: "\t}\n\n\tvar repos []*api.Repository\n\trepoMap := map[string]bool{}\n\n\tadd := func(r *api.Repository) {\n\t\tfn := ghrepo.FullName(r)",
173 Matches: []search.Match{
174 {
175 Text: "Map",
176 Indices: []int{38, 41},
177 },
178 {
179 Text: "map",
180 Indices: []int{45, 48},
181 },
182 },
183 },
184 },
185 },
186 {
187 Name: "pr.go",
188 Path: "pkg/cmd/pr/pr.go",
189 Repository: search.Repository{
190 FullName: "cli/cli",
191 },
192 TextMatches: []search.TextMatch{

Callers

nothing calls this directly

Calls 13

SetDefaultHostMethod · 0.95
VerifyMethod · 0.95
NewBlankConfigFunction · 0.92
NewSearcherFunction · 0.92
TestFunction · 0.92
codeRunFunction · 0.85
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
ErrorfMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected