Added wantErrOut property
This commit is contained in:
parent
658443f78b
commit
b8302311fa
1 changed files with 15 additions and 16 deletions
|
|
@ -76,12 +76,13 @@ func Test_statusRun(t *testing.T) {
|
|||
readConfigs := config.StubWriteConfig(t)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
opts *StatusOptions
|
||||
httpStubs func(*httpmock.Registry)
|
||||
cfgStubs func(*config.ConfigMock)
|
||||
wantErr string
|
||||
wantOut string
|
||||
name string
|
||||
opts *StatusOptions
|
||||
httpStubs func(*httpmock.Registry)
|
||||
cfgStubs func(*config.ConfigMock)
|
||||
wantErr string
|
||||
wantOut string
|
||||
wantErrOut string
|
||||
}{
|
||||
{
|
||||
name: "hostname set",
|
||||
|
|
@ -126,7 +127,7 @@ func Test_statusRun(t *testing.T) {
|
|||
httpmock.StringResponse(`{"data":{"viewer":{"login":"tess"}}}`))
|
||||
},
|
||||
wantErr: "SilentError",
|
||||
wantOut: heredoc.Doc(`
|
||||
wantErrOut: heredoc.Doc(`
|
||||
joel.miller
|
||||
X joel.miller: the token in GH_CONFIG_DIR/hosts.yml is missing required scope 'read:org'
|
||||
- To request missing scopes, run: gh auth refresh -h joel.miller
|
||||
|
|
@ -156,7 +157,7 @@ func Test_statusRun(t *testing.T) {
|
|||
httpmock.StringResponse(`{"data":{"viewer":{"login":"tess"}}}`))
|
||||
},
|
||||
wantErr: "SilentError",
|
||||
wantOut: heredoc.Doc(`
|
||||
wantErrOut: heredoc.Doc(`
|
||||
joel.miller
|
||||
X joel.miller: authentication failed
|
||||
- The joel.miller token in GH_CONFIG_DIR/hosts.yml is no longer valid.
|
||||
|
|
@ -298,9 +299,9 @@ func Test_statusRun(t *testing.T) {
|
|||
cfgStubs: func(c *config.ConfigMock) {
|
||||
c.Set("github.com", "oauth_token", "abc123")
|
||||
},
|
||||
httpStubs: func(reg *httpmock.Registry) {},
|
||||
wantErr: "SilentError",
|
||||
wantOut: "Hostname \"github.example.com\" not found among authenticated GitHub hosts\n",
|
||||
httpStubs: func(reg *httpmock.Registry) {},
|
||||
wantErr: "SilentError",
|
||||
wantErrOut: "Hostname \"github.example.com\" not found among authenticated GitHub hosts\n",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -341,11 +342,9 @@ func Test_statusRun(t *testing.T) {
|
|||
}
|
||||
output := strings.ReplaceAll(stdout.String(), config.ConfigDir()+string(filepath.Separator), "GH_CONFIG_DIR/")
|
||||
errorOutput := strings.ReplaceAll(stderr.String(), config.ConfigDir()+string(filepath.Separator), "GH_CONFIG_DIR/")
|
||||
if output != "" {
|
||||
assert.Equal(t, tt.wantOut, output)
|
||||
} else {
|
||||
assert.Equal(t, tt.wantOut, errorOutput)
|
||||
}
|
||||
|
||||
assert.Equal(t, tt.wantErrOut, errorOutput)
|
||||
assert.Equal(t, tt.wantOut, output)
|
||||
|
||||
mainBuf := bytes.Buffer{}
|
||||
hostsBuf := bytes.Buffer{}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue