77 "strings"
88 "testing"
99
10+ "github.com/docker/app/internal/relocated"
11+
1012 "github.com/deislabs/cnab-go/bundle"
1113 "github.com/deislabs/cnab-go/bundle/definition"
1214 "github.com/deislabs/cnab-go/claim"
@@ -113,18 +115,18 @@ func withParameterAndValues(name, typ string, allowedValues []interface{}) bundl
113115 }
114116}
115117
116- func prepareBundle (ops ... bundleOperator ) * bundle .Bundle {
117- b := & bundle.Bundle {}
118+ func prepareBundle (ops ... bundleOperator ) * relocated .Bundle {
119+ b := relocated . FromBundle ( & bundle.Bundle {})
118120 for _ , op := range ops {
119- op (b )
121+ op (b . Bundle )
120122 }
121123 return b
122124}
123125
124126func TestWithOrchestratorParameters (t * testing.T ) {
125127 testCases := []struct {
126128 name string
127- bundle * bundle .Bundle
129+ bundle * relocated .Bundle
128130 expected map [string ]string
129131 }{
130132 {
@@ -146,7 +148,7 @@ func TestWithOrchestratorParameters(t *testing.T) {
146148 t .Run (testCase .name , func (t * testing.T ) {
147149 actual := map [string ]string {}
148150 err := WithOrchestratorParameters ("kubernetes" , "my-namespace" )(& MergeBundleConfig {
149- bundle : testCase .bundle ,
151+ bundle : testCase .bundle . Bundle ,
150152 params : actual ,
151153 })
152154 assert .NilError (t , err )
@@ -166,7 +168,10 @@ func TestMergeBundleParameters(t *testing.T) {
166168 return nil
167169 }
168170 bundle := prepareBundle (withParameterAndDefault ("param" , "string" , "default" ))
169- i := & store.Installation {Claim : claim.Claim {Bundle : bundle }}
171+ i := & store.Installation {
172+ Claim : claim.Claim {Bundle : bundle .Bundle },
173+ RelocationMap : bundle .RelocationMap ,
174+ }
170175 err := MergeBundleParameters (i ,
171176 first ,
172177 second ,
@@ -180,7 +185,10 @@ func TestMergeBundleParameters(t *testing.T) {
180185
181186 t .Run ("Default values" , func (t * testing.T ) {
182187 bundle := prepareBundle (withParameterAndDefault ("param" , "string" , "default" ))
183- i := & store.Installation {Claim : claim.Claim {Bundle : bundle }}
188+ i := & store.Installation {
189+ Claim : claim.Claim {Bundle : bundle .Bundle },
190+ RelocationMap : bundle .RelocationMap ,
191+ }
184192 err := MergeBundleParameters (i )
185193 assert .NilError (t , err )
186194 expected := map [string ]interface {}{
@@ -195,7 +203,10 @@ func TestMergeBundleParameters(t *testing.T) {
195203 return nil
196204 }
197205 bundle := prepareBundle (withParameter ("param" , "integer" ))
198- i := & store.Installation {Claim : claim.Claim {Bundle : bundle }}
206+ i := & store.Installation {
207+ Claim : claim.Claim {Bundle : bundle .Bundle },
208+ RelocationMap : bundle .RelocationMap ,
209+ }
199210 err := MergeBundleParameters (i , withIntValue )
200211 assert .NilError (t , err )
201212 expected := map [string ]interface {}{
@@ -206,7 +217,10 @@ func TestMergeBundleParameters(t *testing.T) {
206217
207218 t .Run ("Default values" , func (t * testing.T ) {
208219 bundle := prepareBundle (withParameterAndDefault ("param" , "string" , "default" ))
209- i := & store.Installation {Claim : claim.Claim {Bundle : bundle }}
220+ i := & store.Installation {
221+ Claim : claim.Claim {Bundle : bundle .Bundle },
222+ RelocationMap : bundle .RelocationMap ,
223+ }
210224 err := MergeBundleParameters (i )
211225 assert .NilError (t , err )
212226 expected := map [string ]interface {}{
@@ -221,7 +235,10 @@ func TestMergeBundleParameters(t *testing.T) {
221235 return nil
222236 }
223237 bundle := prepareBundle ()
224- i := & store.Installation {Claim : claim.Claim {Bundle : bundle }}
238+ i := & store.Installation {
239+ Claim : claim.Claim {Bundle : bundle .Bundle },
240+ RelocationMap : bundle .RelocationMap ,
241+ }
225242 buf := new (bytes.Buffer )
226243 err := MergeBundleParameters (i , withUndefined , WithErrorWriter (buf ))
227244 assert .NilError (t , err )
@@ -239,7 +256,10 @@ func TestMergeBundleParameters(t *testing.T) {
239256 return nil
240257 }
241258 bundle := prepareBundle ()
242- i := & store.Installation {Claim : claim.Claim {Bundle : bundle }}
259+ i := & store.Installation {
260+ Claim : claim.Claim {Bundle : bundle .Bundle },
261+ RelocationMap : bundle .RelocationMap ,
262+ }
243263 err := MergeBundleParameters (i , withUndefined , withStdErr )
244264 assert .NilError (t , err )
245265 assert .Equal (t , w .String (), "Warning: parameter \" param\" is not defined in the bundle\n " )
@@ -251,7 +271,10 @@ func TestMergeBundleParameters(t *testing.T) {
251271 return nil
252272 }
253273 bundle := prepareBundle (withParameter ("param" , "integer" ))
254- i := & store.Installation {Claim : claim.Claim {Bundle : bundle }}
274+ i := & store.Installation {
275+ Claim : claim.Claim {Bundle : bundle .Bundle },
276+ RelocationMap : bundle .RelocationMap ,
277+ }
255278 err := MergeBundleParameters (i , withIntValue )
256279 assert .ErrorContains (t , err , "invalid value for parameter" )
257280 })
@@ -262,7 +285,10 @@ func TestMergeBundleParameters(t *testing.T) {
262285 return nil
263286 }
264287 bundle := prepareBundle (withParameterAndValues ("param" , "string" , []interface {}{"valid" }))
265- i := & store.Installation {Claim : claim.Claim {Bundle : bundle }}
288+ i := & store.Installation {
289+ Claim : claim.Claim {Bundle : bundle .Bundle },
290+ RelocationMap : bundle .RelocationMap ,
291+ }
266292 err := MergeBundleParameters (i , withInvalidValue )
267293 assert .ErrorContains (t , err , "invalid value for parameter" )
268294 })
0 commit comments