Skip to content

Commit

Permalink
chore: use testify instead of testing.Fatal or testing.Error in cmd
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 committed Nov 11, 2024
1 parent 0dacc2e commit fa62a82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
9 changes: 3 additions & 6 deletions cmd/argocd/commands/utils/prompt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestNewPrompt_PromptsEnabled_True(t *testing.T) {
Expand Down Expand Up @@ -57,9 +58,7 @@ func TestConfirmPrompt(t *testing.T) {

for _, c := range cases {
tmpFile, err := writeToStdin(c.input)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
p := &Prompt{enabled: true}
result := p.Confirm("Are you sure you want to run this command? (y/n) \n")
assert.Equal(t, c.output, result)
Expand All @@ -85,9 +84,7 @@ func TestConfirmAllPrompt(t *testing.T) {

for _, c := range cases {
tmpFile, err := writeToStdin(c.input)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)
p := &Prompt{enabled: true}
confirm, confirmAll := p.ConfirmAll("Are you sure you want to run this command? (y/n) \n")
assert.Equal(t, c.confirm, confirm)
Expand Down
3 changes: 1 addition & 2 deletions cmd/argocd/commands/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ func TestShortVersionClient(t *testing.T) {
cmd.SetOut(buf)
cmd.SetArgs([]string{"version", "--short", "--client"})
require.NoError(t, cmd.Execute(), "Failed to execute short version command")
output := buf.String()
assert.Equal(t, "argocd: v99.99.99+unknown\n", output)
assert.Equal(t, "argocd: v99.99.99+unknown\n", buf.String())
}

func TestShortVersion(t *testing.T) {
Expand Down

0 comments on commit fa62a82

Please sign in to comment.