1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00

support list/map/scalar for on and needs

Signed-off-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
Casey Lee 2020-02-10 16:35:00 -08:00
parent ff5f860cee
commit a846112993
33 changed files with 2451 additions and 1690 deletions

View file

@ -0,0 +1,68 @@
package model
import (
"strings"
"testing"
"gotest.tools/assert"
)
func TestReadWorkflow_StringEvent(t *testing.T) {
yaml := `
name: local-action-docker-url
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: ./actions/docker-url
`
workflow, err := ReadWorkflow(strings.NewReader(yaml))
assert.NilError(t, err, "read workflow should succeed")
assert.DeepEqual(t, workflow.On(), []string{"push"})
}
func TestReadWorkflow_ListEvent(t *testing.T) {
yaml := `
name: local-action-docker-url
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: ./actions/docker-url
`
workflow, err := ReadWorkflow(strings.NewReader(yaml))
assert.NilError(t, err, "read workflow should succeed")
assert.DeepEqual(t, workflow.On(), []string{"push", "pull_request"})
}
func TestReadWorkflow_MapEvent(t *testing.T) {
yaml := `
name: local-action-docker-url
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: ./actions/docker-url
`
workflow, err := ReadWorkflow(strings.NewReader(yaml))
assert.NilError(t, err, "read workflow should succeed")
assert.DeepEqual(t, workflow.On(), []string{"push", "pull_request"})
}