MCPcopy
hub / github.com/cli/cli / TestRepoList_tty

Function TestRepoList_tty

pkg/cmd/repo/list/list_test.go:424–467  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

422}
423
424func TestRepoList_tty(t *testing.T) {
425 ios, _, stdout, stderr := iostreams.Test()
426 ios.SetStdoutTTY(true)
427 ios.SetStdinTTY(true)
428 ios.SetStderrTTY(true)
429
430 httpReg := &httpmock.Registry{}
431 defer httpReg.Verify(t)
432
433 httpReg.Register(
434 httpmock.GraphQL(`query RepositoryList\b`),
435 httpmock.FileResponse("./fixtures/repoList.json"),
436 )
437
438 opts := ListOptions{
439 IO: ios,
440 HttpClient: func() (*http.Client, error) {
441 return &http.Client{Transport: httpReg}, nil
442 },
443 Config: func() (gh.Config, error) {
444 return config.NewBlankConfig(), nil
445 },
446 Now: func() time.Time {
447 t, _ := time.Parse(time.RFC822, "19 Feb 21 15:00 UTC")
448 return t
449 },
450 Limit: 30,
451 }
452
453 err := listRun(&opts)
454 assert.NoError(t, err)
455
456 assert.Equal(t, "", stderr.String())
457
458 assert.Equal(t, heredoc.Doc(`
459
460 Showing 3 of 3 repositories in @octocat
461
462 NAME DESCRIPTION INFO UPDATED
463 octocat/hello-world My first repository public about 8 hours ago
464 octocat/cli GitHub CLI public, fork about 8 hours ago
465 octocat/testing private about 7 days ago
466 `), stdout.String())
467}
468
469func TestRepoList_filtering(t *testing.T) {
470 http := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 12

VerifyMethod · 0.95
RegisterMethod · 0.95
TestFunction · 0.92
GraphQLFunction · 0.92
FileResponseFunction · 0.92
NewBlankConfigFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
listRunFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected