.github
.vscode
cmd
pkg
artifacts
common
container
exprparser
lookpath
model
testdata
action.go
github_context.go
github_context_test.go
job_context.go
planner.go
planner_test.go
step_result.go
workflow.go
workflow_test.go
runner
.actrc
.editorconfig
.gitignore
.gitleaksignore
.golangci.yml
.goreleaser.yml
.markdownlint.yml
.mega-linter.yml
.mergify.yml
.prettierignore
.prettierrc.yml
CODEOWNERS
CONTRIBUTING.md
IMAGES.md
LICENSE
Makefile
README.md
VERIFICATION
VERSION
act-cli.nuspec
codecov.yml
go.mod
go.sum
install.sh
main.go
* refactor: split out common/git * refactor: move git options to separate func * refactor: remove github.com/pkg/errors dependency * fix(golangci-lint): forbid github.com/pkg/errors * style: fix typo * style: fix typo Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
42 lines
1.5 KiB
Go
42 lines
1.5 KiB
Go
package model
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
type WorkflowPlanTest struct {
|
|
workflowPath string
|
|
errorMessage string
|
|
noWorkflowRecurse bool
|
|
}
|
|
|
|
func TestPlanner(t *testing.T) {
|
|
log.SetLevel(log.DebugLevel)
|
|
|
|
tables := []WorkflowPlanTest{
|
|
{"invalid-job-name/invalid-1.yml", "workflow is not valid. 'invalid-job-name-1': Job name 'invalid-JOB-Name-v1.2.3-docker_hub' is invalid. Names must start with a letter or '_' and contain only alphanumeric characters, '-', or '_'", false},
|
|
{"invalid-job-name/invalid-2.yml", "workflow is not valid. 'invalid-job-name-2': Job name '1234invalid-JOB-Name-v123-docker_hub' is invalid. Names must start with a letter or '_' and contain only alphanumeric characters, '-', or '_'", false},
|
|
{"invalid-job-name/valid-1.yml", "", false},
|
|
{"invalid-job-name/valid-2.yml", "", false},
|
|
{"empty-workflow", "unable to read workflow 'push.yml': file is empty: EOF", false},
|
|
{"nested", "unable to read workflow 'fail.yml': file is empty: EOF", false},
|
|
{"nested", "", true},
|
|
}
|
|
|
|
workdir, err := filepath.Abs("testdata")
|
|
assert.NoError(t, err, workdir)
|
|
for _, table := range tables {
|
|
fullWorkflowPath := filepath.Join(workdir, table.workflowPath)
|
|
_, err = NewWorkflowPlanner(fullWorkflowPath, table.noWorkflowRecurse)
|
|
if table.errorMessage == "" {
|
|
assert.NoError(t, err, "WorkflowPlanner should exit without any error")
|
|
} else {
|
|
assert.EqualError(t, err, table.errorMessage)
|
|
}
|
|
}
|
|
}
|