Commit cc48c176
cc48c17625e1Merged
Dmitrii Zhiliaev <[email protected]> ยท 1 year ago ยท 1 file ยท ~1 modified
Description
fix: test panic
Details
- Commit
- cc48c17625e1
- Parent
- e3926b0a2f98
cmd/helmwave/completion_internal_test.gomodifiedView file
@@ -1,5 +1,7 @@
11
package main22
3+
import "github.com/stretchr/testify/assert"4+
35
func (ts *CliTestSuite) TestCompletion() {46
tests := []struct {57
args []string@@ -7,7 +9,7 @@
79
}{810
{911
args: []string{"helmwave", "completion"},10-
fails: true,12+
fails: false,1113
},1214
{1315
args: []string{"helmwave", "completion", "bash"},@@ -18,6 +20,10 @@
1820
fails: false,1921
},2022
{23+
args: []string{"helmwave", "completion", "fish"},24+
fails: false,25+
},26+
{2127
args: []string{"helmwave", "completion", "ash"},2228
fails: true,2329
},@@ -25,14 +31,17 @@
2531
2632
app, _, _, _ := ts.prepareApp() //nolint:dogsled // no need to access nor stdin or stdout or stderr2733
28-
for i := range tests {29-
tt := tests[i]30-
31-
err := app.Run(tt.args)34+
for _, tt := range tests {3235
if tt.fails {33-
ts.Error(err)36+
assert.Panics(ts.T(), func() {37+
err := app.Run(tt.args)38+
assert.NoError(ts.T(), err, "unexpected error occurred")39+
}, "Expected panic when args are: %v", tt.args)3440
} else {35-
ts.NoError(err)41+
assert.NotPanics(ts.T(), func() {42+
err := app.Run(tt.args)43+
assert.NoError(ts.T(), err, "unexpected error occurred")44+
}, "Unexpected panic for args: %v", tt.args)3645
}3746
}3847
}