[wip] error-action: added invalid test case

This commit is contained in:
Tigor Hutasuhut 2024-06-25 16:55:52 +07:00
parent f0feb88d5a
commit 0ad2e1a1e1

View file

@ -12,6 +12,7 @@ func TestErrorAction_UnmarshalYAML(t *testing.T) {
name string
input []byte
want ErrorAction
wantErr bool
}{
{
name: "continue",
@ -63,6 +64,11 @@ func TestErrorAction_UnmarshalYAML(t *testing.T) {
input: []byte(`E: stop-run`),
want: ErrorActionStopRun,
},
{
name: "error on invalid value",
input: []byte(`E: invalid`),
wantErr: true,
},
}
type placeholder struct {
E ErrorAction `yaml:"E"`
@ -71,6 +77,10 @@ func TestErrorAction_UnmarshalYAML(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
var placeholder placeholder
err := yaml.Unmarshal(tt.input, &placeholder)
if tt.wantErr {
assert.Error(t, err)
return
}
if !assert.NoError(t, err) {
return
}