From 107867c771059008931a0ba2d103313fcbd88d50 Mon Sep 17 00:00:00 2001 From: Don Date: Fri, 4 Nov 2016 12:32:53 -0700 Subject: [PATCH] Add test for variable expansion --- yaml/config_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/yaml/config_test.go b/yaml/config_test.go index 5e5e780cc..e20add807 100644 --- a/yaml/config_test.go +++ b/yaml/config_test.go @@ -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 +`