MCPcopy
hub / github.com/cli/cli / TestRepoList_nontty

Function TestRepoList_nontty

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

Source from the content-addressed store, hash-verified

381}
382
383func TestRepoList_nontty(t *testing.T) {
384 ios, _, stdout, stderr := iostreams.Test()
385 ios.SetStdoutTTY(false)
386 ios.SetStdinTTY(false)
387 ios.SetStderrTTY(false)
388
389 httpReg := &httpmock.Registry{}
390 defer httpReg.Verify(t)
391
392 httpReg.Register(
393 httpmock.GraphQL(`query RepositoryList\b`),
394 httpmock.FileResponse("./fixtures/repoList.json"),
395 )
396
397 opts := ListOptions{
398 IO: ios,
399 HttpClient: func() (*http.Client, error) {
400 return &http.Client{Transport: httpReg}, nil
401 },
402 Config: func() (gh.Config, error) {
403 return config.NewBlankConfig(), nil
404 },
405 Now: func() time.Time {
406 t, _ := time.Parse(time.RFC822, "19 Feb 21 15:00 UTC")
407 return t
408 },
409 Limit: 30,
410 }
411
412 err := listRun(&opts)
413 assert.NoError(t, err)
414
415 assert.Equal(t, "", stderr.String())
416
417 assert.Equal(t, heredoc.Doc(`
418 octocat/hello-world My first repository public 2021-02-19T06:34:58Z
419 octocat/cli GitHub CLI public, fork 2021-02-19T06:06:06Z
420 octocat/testing private 2021-02-11T22:32:05Z
421 `), stdout.String())
422}
423
424func TestRepoList_tty(t *testing.T) {
425 ios, _, stdout, stderr := iostreams.Test()

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