Ensure that tests for command factory never read from user's config
If these tests are going to exerise `factory.New()`, the config getter should always be overriden since the default config getter reads from `~/.config/gh` and thus makes tests dependent on the user's environment.
This commit is contained in:
parent
dd3aac7f52
commit
4b2cded1f8
1 changed files with 8 additions and 4 deletions
|
|
@ -333,8 +333,10 @@ func Test_ioStreams_pager(t *testing.T) {
|
|||
}
|
||||
}
|
||||
f := New("1")
|
||||
if tt.config != nil {
|
||||
f.Config = func() (config.Config, error) {
|
||||
f.Config = func() (config.Config, error) {
|
||||
if tt.config == nil {
|
||||
return config.NewBlankConfig(), nil
|
||||
} else {
|
||||
return tt.config, nil
|
||||
}
|
||||
}
|
||||
|
|
@ -363,8 +365,10 @@ func Test_ioStreams_prompt(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
f := New("1")
|
||||
if tt.config != nil {
|
||||
f.Config = func() (config.Config, error) {
|
||||
f.Config = func() (config.Config, error) {
|
||||
if tt.config == nil {
|
||||
return config.NewBlankConfig(), nil
|
||||
} else {
|
||||
return tt.config, nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue