refactor: NewWorkflowPlanner (#648)

feat: add flag `--no-recurse` to disable recursion when reading workflows from directories
feat: added more tests to `TestPlanner`, renamed `TestJobFileInfo` to more appropriate name `WorkflowPlanTest`
style: changed error message to lowercase, added single quotes for better visibility

Co-authored-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
Ryan (hackercat)
2021-05-03 16:57:24 +02:00
committed by GitHub
parent b04d762614
commit 806bc4d999
11 changed files with 117 additions and 31 deletions

View File

@@ -14,7 +14,7 @@ import (
)
func TestGraphEvent(t *testing.T) {
planner, err := model.NewWorkflowPlanner("testdata/basic")
planner, err := model.NewWorkflowPlanner("testdata/basic", true)
assert.NilError(t, err)
plan := planner.PlanEvent("push")
@@ -56,7 +56,7 @@ func runTestJobFile(ctx context.Context, t *testing.T, tjfi TestJobFileInfo) {
runner, err := New(runnerConfig)
assert.NilError(t, err, tjfi.workflowPath)
planner, err := model.NewWorkflowPlanner(fullWorkflowPath)
planner, err := model.NewWorkflowPlanner(fullWorkflowPath, true)
assert.NilError(t, err, fullWorkflowPath)
plan := planner.PlanEvent(tjfi.eventName)
@@ -143,7 +143,7 @@ func TestRunEventSecrets(t *testing.T) {
runner, err := New(runnerConfig)
assert.NilError(t, err, workflowPath)
planner, err := model.NewWorkflowPlanner(fmt.Sprintf("testdata/%s", workflowPath))
planner, err := model.NewWorkflowPlanner(fmt.Sprintf("testdata/%s", workflowPath), true)
assert.NilError(t, err, workflowPath)
plan := planner.PlanEvent(eventName)
@@ -180,7 +180,7 @@ func TestRunEventPullRequest(t *testing.T) {
runner, err := New(runnerConfig)
assert.NilError(t, err, workflowPath)
planner, err := model.NewWorkflowPlanner(fmt.Sprintf("testdata/%s", workflowPath))
planner, err := model.NewWorkflowPlanner(fmt.Sprintf("testdata/%s", workflowPath), true)
assert.NilError(t, err, workflowPath)
plan := planner.PlanEvent(eventName)