1package flow
2
3import (
4	. "github.com/onsi/ginkgo"
5	. "github.com/onsi/gomega"
6)
7
8var _ = Describe("Cascading YAML templates", func() {
9	It("flows through multiple templates", func() {
10		source := parseYAML(`
11---
12foo: (( merge ))
13baz: 42
14`)
15
16		secondary := parseYAML(`
17---
18foo:
19  bar: (( merge ))
20  xyz: (( bar ))
21`)
22
23		stub := parseYAML(`
24---
25foo:
26  bar: merged!
27`)
28
29		resolved := parseYAML(`
30---
31foo:
32  bar: merged!
33  xyz: merged!
34baz: 42
35`)
36
37		Expect(source).To(CascadeAs(resolved, secondary, stub))
38	})
39
40	Context("with multiple mutually-exclusive templates", func() {
41		It("flows through both", func() {
42			source := parseYAML(`
43---
44foo: (( merge ))
45baz: (( merge ))
46`)
47
48			secondary := parseYAML(`
49---
50foo:
51  bar: (( merge ))
52`)
53
54			tertiary := parseYAML(`
55---
56baz:
57  a: 1
58  b: (( merge ))
59`)
60
61			stub := parseYAML(`
62---
63foo:
64  bar: merged!
65baz:
66  b: 2
67`)
68
69			resolved := parseYAML(`
70---
71foo:
72  bar: merged!
73baz:
74  a: 1
75  b: 2
76`)
77
78			Expect(source).To(CascadeAs(resolved, secondary, tertiary, stub))
79		})
80	})
81})
82