2019-01-31 01:53:39 -06:00
|
|
|
package actions
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"gotest.tools/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestRunEvent(t *testing.T) {
|
2019-02-07 11:09:19 -06:00
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("skipping integration test")
|
|
|
|
}
|
|
|
|
|
2019-01-31 01:53:39 -06:00
|
|
|
tables := []struct {
|
|
|
|
workflowPath string
|
|
|
|
eventName string
|
|
|
|
errorMessage string
|
|
|
|
}{
|
|
|
|
{"basic.workflow", "push", ""},
|
|
|
|
{"pipe.workflow", "push", ""},
|
|
|
|
{"fail.workflow", "push", "exit with `FAILURE`: 1"},
|
2019-03-01 21:36:07 -06:00
|
|
|
{"buildfail.workflow", "push", "COPY failed"},
|
2019-01-31 01:53:39 -06:00
|
|
|
{"regex.workflow", "push", "exit with `NEUTRAL`: 78"},
|
2019-02-07 11:09:19 -06:00
|
|
|
{"gitref.workflow", "push", ""},
|
|
|
|
{"env.workflow", "push", ""},
|
2019-02-15 10:44:36 -06:00
|
|
|
{"detect_event.workflow", "", ""},
|
2019-01-31 01:53:39 -06:00
|
|
|
}
|
|
|
|
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 == "" {
|
|
|
|
assert.NilError(t, err, table.workflowPath)
|
|
|
|
} else {
|
2019-03-01 21:36:07 -06:00
|
|
|
assert.ErrorContains(t, err, table.errorMessage)
|
2019-01-31 01:53:39 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|