MCPcopy
hub / github.com/cli/cli / TestReposRun

Function TestReposRun

pkg/cmd/search/repos/repos_test.go:151–287  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

149}
150
151func TestReposRun(t *testing.T) {
152 var now = time.Date(2022, 2, 28, 12, 30, 0, 0, time.UTC)
153 var updatedAt = time.Date(2021, 2, 28, 12, 30, 0, 0, time.UTC)
154 var query = search.Query{
155 Keywords: []string{"cli"},
156 Kind: "repositories",
157 Limit: 30,
158 Qualifiers: search.Qualifiers{
159 Stars: ">50",
160 Topic: []string{"golang"},
161 },
162 }
163 tests := []struct {
164 errMsg string
165 name string
166 opts *ReposOptions
167 tty bool
168 wantErr bool
169 wantStderr string
170 wantStdout string
171 }{
172 {
173 name: "displays results tty",
174 opts: &ReposOptions{
175 Query: query,
176 Searcher: &search.SearcherMock{
177 RepositoriesFunc: func(query search.Query) (search.RepositoriesResult, error) {
178 return search.RepositoriesResult{
179 IncompleteResults: false,
180 Items: []search.Repository{
181 {FullName: "test/cli", Description: "of course", IsPrivate: true, IsArchived: true, UpdatedAt: updatedAt, Visibility: "private"},
182 {FullName: "test/cliing", Description: "wow", IsFork: true, UpdatedAt: updatedAt, Visibility: "public"},
183 {FullName: "cli/cli", Description: "so much", IsArchived: false, UpdatedAt: updatedAt, Visibility: "internal"},
184 },
185 Total: 300,
186 }, nil
187 },
188 },
189 },
190 tty: true,
191 wantStdout: "\nShowing 3 of 300 repositories\n\nNAME DESCRIPTION VISIBILITY UPDATED\ntest/cli of course private, archived about 1 year ago\ntest/cliing wow public, fork about 1 year ago\ncli/cli so much internal about 1 year ago\n",
192 },
193 {
194 name: "displays results notty",
195 opts: &ReposOptions{
196 Query: query,
197 Searcher: &search.SearcherMock{
198 RepositoriesFunc: func(query search.Query) (search.RepositoriesResult, error) {
199 return search.RepositoriesResult{
200 IncompleteResults: false,
201 Items: []search.Repository{
202 {FullName: "test/cli", Description: "of course", IsPrivate: true, IsArchived: true, UpdatedAt: updatedAt, Visibility: "private"},
203 {FullName: "test/cliing", Description: "wow", IsFork: true, UpdatedAt: updatedAt, Visibility: "public"},
204 {FullName: "cli/cli", Description: "so much", IsArchived: false, UpdatedAt: updatedAt, Visibility: "internal"},
205 },
206 Total: 300,
207 }, nil
208 },

Callers

nothing calls this directly

Calls 9

TestFunction · 0.92
reposRunFunction · 0.85
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
ErrorfMethod · 0.65
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected