Resolve tests/lint errors

This commit is contained in:
rajhawaldar 2023-06-07 08:23:59 +05:30
parent 69c02b9b8a
commit 437b78a955
2 changed files with 9 additions and 6 deletions

View file

@ -168,7 +168,7 @@ func statusRun(opts *StatusOptions) error {
}
if prevEntry && failed {
fmt.Fprint(stderr, "\n")
} else if prevEntry && failed == false {
} else if prevEntry && !failed {
fmt.Fprint(stdout, "\n")
}
prevEntry = true

View file

@ -310,13 +310,12 @@ func Test_statusRun(t *testing.T) {
tt.opts = &StatusOptions{}
}
ios, _, _, stderr := iostreams.Test()
ios, _, stdout, stderr := iostreams.Test()
ios.SetStdinTTY(true)
ios.SetStderrTTY(true)
ios.SetStdoutTTY(true)
tt.opts.IO = ios
cfg := config.NewFromString("")
if tt.cfgStubs != nil {
tt.cfgStubs(cfg)
@ -340,9 +339,13 @@ func Test_statusRun(t *testing.T) {
} else {
assert.NoError(t, err)
}
output := strings.ReplaceAll(stderr.String(), config.ConfigDir()+string(filepath.Separator), "GH_CONFIG_DIR/")
assert.Equal(t, tt.wantOut, output)
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)
}
mainBuf := bytes.Buffer{}
hostsBuf := bytes.Buffer{}