@@ -140,3 +140,103 @@ func TestManifestUnMarshalling(t *testing.T) {
140140 require .Equal (t , 1 , len (m .Applications ))
141141 require .Equal (t , 2 , len (* m .Applications [0 ].Services ))
142142}
143+
144+ func TestManifestLifecycle (t * testing.T ) {
145+ t .Run ("Marshall with buildpack lifecycle" , func (t * testing.T ) {
146+ m := & Manifest {
147+ Applications : []* AppManifest {
148+ {
149+ Name : "test-app" ,
150+ Lifecycle : Buildpack ,
151+ },
152+ },
153+ }
154+ b , err := yaml .Marshal (& m )
155+ require .NoError (t , err )
156+ require .Contains (t , string (b ), "lifecycle: buildpack" )
157+ })
158+
159+ t .Run ("Marshall with docker lifecycle" , func (t * testing.T ) {
160+ m := & Manifest {
161+ Applications : []* AppManifest {
162+ {
163+ Name : "test-app" ,
164+ Lifecycle : Docker ,
165+ },
166+ },
167+ }
168+ b , err := yaml .Marshal (& m )
169+ require .NoError (t , err )
170+ require .Contains (t , string (b ), "lifecycle: docker" )
171+ })
172+
173+ t .Run ("Marshall with cnb lifecycle" , func (t * testing.T ) {
174+ m := & Manifest {
175+ Applications : []* AppManifest {
176+ {
177+ Name : "test-app" ,
178+ Lifecycle : CNB ,
179+ },
180+ },
181+ }
182+ b , err := yaml .Marshal (& m )
183+ require .NoError (t , err )
184+ require .Contains (t , string (b ), "lifecycle: cnb" )
185+ })
186+
187+ t .Run ("Marshall without lifecycle (omitempty)" , func (t * testing.T ) {
188+ m := & Manifest {
189+ Applications : []* AppManifest {
190+ {
191+ Name : "test-app" ,
192+ },
193+ },
194+ }
195+ b , err := yaml .Marshal (& m )
196+ require .NoError (t , err )
197+ require .NotContains (t , string (b ), "lifecycle:" )
198+ })
199+
200+ t .Run ("Unmarshall with buildpack lifecycle" , func (t * testing.T ) {
201+ yamlData := `applications:
202+ - name: test-app
203+ lifecycle: buildpack`
204+
205+ var m Manifest
206+ err := yaml .Unmarshal ([]byte (yamlData ), & m )
207+ require .NoError (t , err )
208+ require .Equal (t , Buildpack , m .Applications [0 ].Lifecycle )
209+ })
210+
211+ t .Run ("Unmarshall with docker lifecycle" , func (t * testing.T ) {
212+ yamlData := `applications:
213+ - name: test-app
214+ lifecycle: docker`
215+
216+ var m Manifest
217+ err := yaml .Unmarshal ([]byte (yamlData ), & m )
218+ require .NoError (t , err )
219+ require .Equal (t , Docker , m .Applications [0 ].Lifecycle )
220+ })
221+
222+ t .Run ("Unmarshall with cnb lifecycle" , func (t * testing.T ) {
223+ yamlData := `applications:
224+ - name: test-app
225+ lifecycle: cnb`
226+
227+ var m Manifest
228+ err := yaml .Unmarshal ([]byte (yamlData ), & m )
229+ require .NoError (t , err )
230+ require .Equal (t , CNB , m .Applications [0 ].Lifecycle )
231+ })
232+
233+ t .Run ("Unmarshall without lifecycle (empty)" , func (t * testing.T ) {
234+ yamlData := `applications:
235+ - name: test-app`
236+
237+ var m Manifest
238+ err := yaml .Unmarshal ([]byte (yamlData ), & m )
239+ require .NoError (t , err )
240+ require .Equal (t , AppLifecycle ("" ), m .Applications [0 ].Lifecycle )
241+ })
242+ }
0 commit comments