Add test for variable expansion

This commit is contained in:
Don 2016-11-04 12:32:53 -07:00
parent 27e807bcda
commit 107867c771

View file

@ -37,6 +37,19 @@ func TestParse(t *testing.T) {
g.Assert(out.Pipeline[2].Name).Equal("notify")
g.Assert(out.Pipeline[2].Image).Equal("slack")
})
// Check to make sure variable expansion works in yaml.MapSlice
g.It("Should unmarshal variables", func() {
out, err := ParseString(sampleVarYaml)
if err != nil {
g.Fail(err)
}
g.Assert(out.Pipeline[0].Name).Equal("notify_fail")
g.Assert(out.Pipeline[0].Image).Equal("plugins/slack")
g.Assert(len(out.Pipeline[0].Constraints.Event.Include)).Equal(0)
g.Assert(out.Pipeline[1].Name).Equal("notify_success")
g.Assert(out.Pipeline[1].Image).Equal("plugins/slack")
g.Assert(out.Pipeline[1].Constraints.Event.Include).Equal([]string{"success"})
})
})
})
}
@ -81,3 +94,15 @@ volumes:
custom:
driver: blockbridge
`
var sampleVarYaml = `
_slack: &SLACK
image: plugins/slack
pipeline:
notify_fail: *SLACK
notify_success:
<< : *SLACK
when:
event: success
`