Fix error message text & add test case
This commit is contained in:
parent
2f5ffbd60a
commit
f3fcaf6c9c
2 changed files with 14 additions and 3 deletions
|
|
@ -143,7 +143,7 @@ func statusRun(opts *StatusOptions) error {
|
|||
|
||||
if !isHostnameFound {
|
||||
fmt.Fprintf(stderr,
|
||||
"You are not logged into any GitHub hosts. Run %s to authenticate.\n", cs.Bold(fmt.Sprintf("gh auth login -h %s", opts.Hostname)))
|
||||
"Hostname %q not found among authenticated GitHub hosts\n", opts.Hostname)
|
||||
return cmdutil.SilentError
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,6 +190,17 @@ func Test_statusRun(t *testing.T) {
|
|||
httpmock.StringResponse(`{"data":{"viewer":{"login":"tess"}}}`))
|
||||
},
|
||||
wantErrOut: regexp.MustCompile(`(?s)Token: xyz456.*Token: abc123`),
|
||||
}, {
|
||||
name: "missing hostname",
|
||||
opts: &StatusOptions{
|
||||
Hostname: "github.example.com",
|
||||
},
|
||||
cfg: func(c config.Config) {
|
||||
_ = c.Set("github.com", "oauth_token", "abc123")
|
||||
},
|
||||
httpStubs: func(reg *httpmock.Registry) {},
|
||||
wantErrOut: regexp.MustCompile(`(?s)Hostname "github.example.com" not found among authenticated GitHub hosts`),
|
||||
wantErr: regexp.MustCompile(``),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -241,9 +252,9 @@ func Test_statusRun(t *testing.T) {
|
|||
if tt.wantErr != nil {
|
||||
assert.True(t, tt.wantErr.MatchString(err.Error()))
|
||||
return
|
||||
} else {
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
|
||||
if tt.wantErrOut == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue