fix: added tests and improved code
This commit is contained in:
@@ -49,20 +49,23 @@ func TestRunEvent(t *testing.T) {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
|
||||
for _, table := range tables {
|
||||
runnerConfig := &RunnerConfig{
|
||||
Ctx: context.Background(),
|
||||
WorkflowPath: table.workflowPath,
|
||||
WorkingDir: "testdata",
|
||||
EventName: table.eventName,
|
||||
}
|
||||
runner, err := NewRunner(runnerConfig)
|
||||
assert.NilError(t, err, table.workflowPath)
|
||||
|
||||
err = runner.RunEvent()
|
||||
if table.errorMessage == "" {
|
||||
table := table
|
||||
t.Run(table.workflowPath, func(t *testing.T) {
|
||||
runnerConfig := &RunnerConfig{
|
||||
Ctx: context.Background(),
|
||||
WorkflowPath: table.workflowPath,
|
||||
WorkingDir: "testdata",
|
||||
EventName: table.eventName,
|
||||
}
|
||||
runner, err := NewRunner(runnerConfig)
|
||||
assert.NilError(t, err, table.workflowPath)
|
||||
} else {
|
||||
assert.ErrorContains(t, err, table.errorMessage)
|
||||
}
|
||||
|
||||
err = runner.RunEvent()
|
||||
if table.errorMessage == "" {
|
||||
assert.NilError(t, err, table.workflowPath)
|
||||
} else {
|
||||
assert.ErrorContains(t, err, table.errorMessage)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
14
actions/testdata/env.workflow
vendored
14
actions/testdata/env.workflow
vendored
@@ -1,9 +1,17 @@
|
||||
workflow "test" {
|
||||
on = "push"
|
||||
resolves = ["test-action"]
|
||||
resolves = [
|
||||
"test-action-repo",
|
||||
"test-action-ref",
|
||||
]
|
||||
}
|
||||
|
||||
action "test-action" {
|
||||
action "test-action-repo" {
|
||||
uses = "docker://alpine:3.9"
|
||||
runs = ["sh", "-c", "echo $GITHUB_REPOSITORY | grep '^nektos/act$'"]
|
||||
}
|
||||
}
|
||||
|
||||
action "test-action-ref" {
|
||||
uses = "docker://alpine:3.9"
|
||||
runs = ["sh", "-c", "echo $GITHUB_REF | grep '^refs/'"]
|
||||
}
|
||||
|
Reference in New Issue
Block a user