Merge pull request #7241 from cli/repo-list-owner-test
repo list: add test for invalid owner error
This commit is contained in:
commit
6e1693eaf0
1 changed files with 37 additions and 0 deletions
|
|
@ -452,3 +452,40 @@ func TestRepoList_noVisibilityField(t *testing.T) {
|
|||
assert.Equal(t, "", stderr.String())
|
||||
assert.Equal(t, "", stdout.String())
|
||||
}
|
||||
|
||||
func TestRepoList_invalidOwner(t *testing.T) {
|
||||
ios, _, stdout, stderr := iostreams.Test()
|
||||
ios.SetStdoutTTY(false)
|
||||
ios.SetStdinTTY(false)
|
||||
ios.SetStderrTTY(false)
|
||||
|
||||
reg := &httpmock.Registry{}
|
||||
defer reg.Verify(t)
|
||||
|
||||
reg.Register(
|
||||
httpmock.GraphQL(`query RepositoryList\b`),
|
||||
httpmock.StringResponse(`{ "data": { "repositoryOwner": null } }`),
|
||||
)
|
||||
|
||||
opts := ListOptions{
|
||||
Owner: "nonexist",
|
||||
IO: ios,
|
||||
HttpClient: func() (*http.Client, error) {
|
||||
return &http.Client{Transport: reg}, nil
|
||||
},
|
||||
Config: func() (config.Config, error) {
|
||||
return config.NewBlankConfig(), nil
|
||||
},
|
||||
Now: func() time.Time {
|
||||
t, _ := time.Parse(time.RFC822, "19 Feb 21 15:00 UTC")
|
||||
return t
|
||||
},
|
||||
Limit: 30,
|
||||
Detector: &fd.DisabledDetectorMock{},
|
||||
}
|
||||
|
||||
err := listRun(&opts)
|
||||
assert.EqualError(t, err, `the owner handle "nonexist" was not recognized as either a GitHub user or an organization`)
|
||||
assert.Equal(t, "", stderr.String())
|
||||
assert.Equal(t, "", stdout.String())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue