Skip to content

Commit

Permalink
Default Triggers to empty slice (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsofdave authored Apr 6, 2018
1 parent 5c9f923 commit 4ee76d1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pipeline/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func (b *Builder) Pipeline() (*types.SpinnakerPipeline, error) {

sp.Notifications = buildNotifications(b.pipeline.Notifications)

sp.Triggers = []types.Trigger{}

for _, trigger := range b.pipeline.Triggers {
if trigger.Jenkins != nil {
jt := trigger.Jenkins
Expand Down
38 changes: 38 additions & 0 deletions pipeline/builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,44 @@ func TestBuilderPipelineStages(t *testing.T) {
wd, _ := os.Getwd()
file := filepath.Join(wd, "testdata", "deployment.full.yml")

t.Run("Triggers", func(t *testing.T) {
t.Run("Defaults to an empty slice", func(t *testing.T) {
pipeline := &config.Pipeline{}

builder := builder.New(pipeline)
spinnaker, err := builder.Pipeline()
require.NoError(t, err, "error generating pipeline json")

assert.Equal(t, []types.Trigger{}, spinnaker.Triggers)
})

t.Run("JenkinsTrigger is parsed correctly", func(t *testing.T) {
pipeline := &config.Pipeline{
Triggers: []config.Trigger{
{
Jenkins: &config.JenkinsTrigger{
Job: "My Job Name",
Master: "namely-jenkins",
PropertyFile: ".test-ci-properties",
},
},
},
}

builder := builder.New(pipeline)
spinnaker, err := builder.Pipeline()
require.NoError(t, err, "error generating pipeline json")

assert.Len(t, spinnaker.Triggers, 1)

assert.Equal(t, true, spinnaker.Triggers[0].(*types.JenkinsTrigger).Enabled)
assert.Equal(t, "My Job Name", spinnaker.Triggers[0].(*types.JenkinsTrigger).Job)
assert.Equal(t, "namely-jenkins", spinnaker.Triggers[0].(*types.JenkinsTrigger).Master)
assert.Equal(t, ".test-ci-properties", spinnaker.Triggers[0].(*types.JenkinsTrigger).PropertyFile)
assert.Equal(t, "jenkins", spinnaker.Triggers[0].(*types.JenkinsTrigger).Type)
})
})

t.Run("Deploy stage is parsed correctly", func(t *testing.T) {
t.Run("Clusters are assigned", func(t *testing.T) {
pipeline := &config.Pipeline{
Expand Down

0 comments on commit 4ee76d1

Please sign in to comment.