Print message on stdout instead of stderr

Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
This commit is contained in:
Babak K. Shandiz 2024-07-16 15:02:22 +01:00
parent c70479ac5d
commit 171e8d33f8
No known key found for this signature in database
GPG key ID: 44950AED81AD710F
2 changed files with 7 additions and 13 deletions

View file

@ -111,7 +111,7 @@ func updateRun(opts *UpdateOptions) error {
cs := opts.IO.ColorScheme()
if comparison.BehindBy == 0 {
// The PR branch is not behind the base branch, so it'a already up-to-date.
fmt.Fprintf(opts.IO.ErrOut, "%s PR branch already up-to-date\n", cs.SuccessIcon())
fmt.Fprintf(opts.IO.Out, "%s PR branch already up-to-date\n", cs.SuccessIcon())
return nil
}
@ -122,7 +122,7 @@ func updateRun(opts *UpdateOptions) error {
return err
}
fmt.Fprintf(opts.IO.ErrOut, "%s PR branch updated\n", cs.SuccessIcon())
fmt.Fprintf(opts.IO.Out, "%s PR branch updated\n", cs.SuccessIcon())
return nil
}

View file

@ -114,7 +114,6 @@ func Test_updateRun(t *testing.T) {
input *UpdateOptions
httpStubs func(*testing.T, *httpmock.Registry)
stdout string
stderr string
wantsErr string
}{
{
@ -152,8 +151,7 @@ func Test_updateRun(t *testing.T) {
assert.Equal(t, "head-repository-owner:head-ref-name", inputs["headRef"])
}))
},
stdout: "",
stderr: "✓ PR branch already up-to-date\n",
stdout: "✓ PR branch already up-to-date\n",
},
{
name: "success, already up-to-date, PR branch on the same repo as base",
@ -189,8 +187,7 @@ func Test_updateRun(t *testing.T) {
assert.Equal(t, "head-ref-name", inputs["headRef"])
}))
},
stdout: "",
stderr: "✓ PR branch already up-to-date\n",
stdout: "✓ PR branch already up-to-date\n",
},
{
name: "success, merge",
@ -232,8 +229,7 @@ func Test_updateRun(t *testing.T) {
assert.Equal(t, "MERGE", inputs["updateMethod"])
}))
},
stdout: "",
stderr: "✓ PR branch updated\n",
stdout: "✓ PR branch updated\n",
},
{
name: "success, rebase",
@ -276,8 +272,7 @@ func Test_updateRun(t *testing.T) {
assert.Equal(t, "REBASE", inputs["updateMethod"])
}))
},
stdout: "",
stderr: "✓ PR branch updated\n",
stdout: "✓ PR branch updated\n",
},
{
name: "failure, API error on ref comparison request",
@ -347,7 +342,7 @@ func Test_updateRun(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ios, _, stdout, stderr := iostreams.Test()
ios, _, stdout, _ := iostreams.Test()
ios.SetStdoutTTY(true)
ios.SetStdinTTY(true)
ios.SetStderrTTY(true)
@ -382,7 +377,6 @@ func Test_updateRun(t *testing.T) {
}
assert.Equal(t, tt.stdout, stdout.String())
assert.Equal(t, tt.stderr, stderr.String())
})
}
}