Skip to content

Commit 0cdc6fd

Browse files
ChristopherHXChristopherHX
authored andcommitted
test: missing shell property in composite action (#20)
Make sure we report schema errors consistently Reviewed-on: https://gitea.com/actions-oss/act-cli/pulls/20 Co-authored-by: Christopher Homberger <christopher.homberger@web.de> Co-committed-by: Christopher Homberger <christopher.homberger@web.de>
1 parent ce08905 commit 0cdc6fd

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

pkg/schema/schema_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,41 @@ jobs:
223223
})
224224
}
225225
}
226+
227+
func TestActionSchemaErrors(t *testing.T) {
228+
table := []struct {
229+
name string // test name
230+
input string // workflow yaml input
231+
err string // error message substring
232+
}{
233+
{
234+
name: "missing property shell",
235+
input: `
236+
runs:
237+
using: composite
238+
steps:
239+
- run: echo failure
240+
`,
241+
err: "missing property shell",
242+
},
243+
}
244+
245+
for _, test := range table {
246+
t.Run(test.name, func(t *testing.T) {
247+
var node yaml.Node
248+
err := yaml.Unmarshal([]byte(test.input), &node)
249+
if !assert.NoError(t, err) {
250+
return
251+
}
252+
err = (&Node{
253+
Definition: "action-root",
254+
Schema: GetActionSchema(),
255+
}).UnmarshalYAML(&node)
256+
if test.err != "" {
257+
assert.ErrorContains(t, err, test.err)
258+
} else {
259+
assert.NoError(t, err)
260+
}
261+
})
262+
}
263+
}

0 commit comments

Comments
 (0)