Skip to content

Commit ddce431

Browse files
cgoetz-inovexrubenhoenle
authored andcommitted
fix(printer) terminate auto-confirmation log with \n, add test
1 parent ccd933e commit ddce431

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

internal/pkg/print/print.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (p *Printer) Error(msg string, args ...any) {
136136
// Returns ErrAborted if the user answers negative.
137137
func (p *Printer) PromptForConfirmation(prompt string) error {
138138
if p.AssumeYes {
139-
p.Warn("Auto-confirming prompt: %q", prompt)
139+
p.Warn("Auto-confirming prompt: %q\n", prompt)
140140
return nil
141141
}
142142
question := fmt.Sprintf("%s [y/N] ", prompt)

internal/pkg/print/print_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ func TestPromptForConfirmation(t *testing.T) {
509509
verbosity Level
510510
isValid bool
511511
isAborted bool
512+
assumeYes bool
512513
}{
513514
// Note: Some of these inputs have normal spaces, others have tabs
514515
{
@@ -647,6 +648,13 @@ func TestPromptForConfirmation(t *testing.T) {
647648
verbosity: DebugLevel,
648649
isValid: false,
649650
},
651+
{
652+
description: "no input with assume yes",
653+
input: "",
654+
verbosity: DebugLevel,
655+
isValid: true,
656+
assumeYes: true,
657+
},
650658
}
651659

652660
for _, tt := range tests {
@@ -665,6 +673,7 @@ func TestPromptForConfirmation(t *testing.T) {
665673
p := &Printer{
666674
Cmd: cmd,
667675
Verbosity: tt.verbosity,
676+
AssumeYes: tt.assumeYes,
668677
}
669678

670679
err = p.PromptForConfirmation("")

0 commit comments

Comments
 (0)