Skip to content

Commit

Permalink
chore: better test coverage for prompt util
Browse files Browse the repository at this point in the history
Signed-off-by: pashakostohrys <[email protected]>
  • Loading branch information
pasha-codefresh committed Nov 5, 2024
1 parent 93253a9 commit 2aaf940
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions cmd/argocd/commands/utils/prompt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ func TestConfirmBaseOnCountZeroApps(t *testing.T) {

func TestConfirmPrompt(t *testing.T) {
cases := []struct {
input string
output bool
input string
output bool
}{
{"y\n", true},
{"n\n", false},
}

origStdin := os.Stdin

for _, c := range cases {
tmpFile, err := writeToStdin(c.input)
if err != nil {
Expand All @@ -71,15 +71,15 @@ func TestConfirmPrompt(t *testing.T) {
os.Remove(tmpFile.Name())
_ = tmpFile.Close()
}

os.Stdin = origStdin
}

func TestConfirmAllPrompt(t *testing.T) {
cases := []struct {
input string
confirm bool
confirmAll bool
input string
confirm bool
confirmAll bool
}{
{"y\n", true, false},
{"n\n", false, false},
Expand Down Expand Up @@ -119,8 +119,8 @@ func writeToStdin(msg string) (*os.File, error) {
if _, err := tmpFile.Seek(0, 0); err != nil {
return nil, err
}

os.Stdin = tmpFile

return tmpFile, nil
}
}

0 comments on commit 2aaf940

Please sign in to comment.