Skip to content

Commit

Permalink
fix: fail if no pipelines are configured
Browse files Browse the repository at this point in the history
  • Loading branch information
fallion committed Dec 31, 2021
1 parent 435bb88 commit 556bc1a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/root_runner/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func (runner *Runner) Run(options RunnerOptions, args ...string) error {
pipelines = append(pipelines, prPipe)
}

if len(pipelines) == 0 {
return errors.New("no pipelines defined")
}

result := dispatch.RunPipelines(pipelines)

if len(result.Errors) != 0 {
Expand Down
18 changes: 18 additions & 0 deletions internal/root_runner/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/apex/log"
"github.com/apex/log/handlers/memory"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -73,3 +74,20 @@ func TestFromToCommits(t *testing.T) {

assert.NoError(t, err)
}

func TestMissingPipelines(t *testing.T) {
handler := memory.New()

log.SetHandler(handler)

runner := Runner{}

viper.Set("commits.disabled", true)

err := runner.Run(RunnerOptions{})

assert.Error(t, err)
assert.Equal(t, "no pipelines defined", err.Error())

viper.Set("commits.disabled", "")
}

0 comments on commit 556bc1a

Please sign in to comment.