@@ -21,14 +21,15 @@ import (
21
21
)
22
22
23
23
type TestMetadata struct {
24
- LicenseID string `yaml:"license_id"`
25
- AppSlug string `yaml:"app_slug"`
26
- InstallationID string `yaml:"installation_id"`
27
- CustomerID string `yaml:"customer_id"`
28
- ReleaseVersion string `yaml:"release_version"`
29
- SetChannelName string `yaml:"set_channel_name"`
30
- Flavor string `yaml:"flavor"`
31
- Args []string `yaml:"args"`
24
+ LicenseID string `yaml:"license_id"`
25
+ AppSlug string `yaml:"app_slug"`
26
+ InstallationID string `yaml:"installation_id"`
27
+ CustomerID string `yaml:"customer_id"`
28
+ ReleaseVersion string `yaml:"release_version"`
29
+ SetChannelName string `yaml:"set_channel_name"`
30
+ Flavor string `yaml:"flavor"`
31
+ Args []string `yaml:"args"`
32
+ Replacements map [string ]string `yaml:"replacements"`
32
33
33
34
// debugging
34
35
SkipCleanup bool `yaml:"skip_cleanup"`
@@ -76,6 +77,10 @@ var _ = Describe("ship init replicated.app/...", func() {
76
77
// read the test metadata
77
78
testMetadata = readMetadata (testPath )
78
79
80
+ if testMetadata .Replacements == nil {
81
+ testMetadata .Replacements = make (map [string ]string )
82
+ }
83
+
79
84
// TODO - instead of getting installation ID, etc from test metadata create a release with the vendor api
80
85
// TODO customer ID and vendor token will need to be read from environment variables
81
86
// TODO so will the desired environment - staging vs prod
@@ -129,13 +134,11 @@ var _ = Describe("ship init replicated.app/...", func() {
129
134
Expect (err ).NotTo (HaveOccurred ())
130
135
131
136
// these strings will be replaced in the "expected" yaml before comparison
132
- replacements := map [string ]string {
133
- "__upstream__" : strings .Replace (upstream , "&" , "\\ u0026" , - 1 ), // this string is encoded within the output
134
- "__installationID__" : testMetadata .InstallationID ,
135
- "__customerID__" : testMetadata .CustomerID ,
136
- "__appSlug__" : testMetadata .AppSlug ,
137
- "__licenseID__" : testMetadata .LicenseID ,
138
- }
137
+ testMetadata .Replacements ["__upstream__" ] = strings .Replace (upstream , "&" , "\\ u0026" , - 1 ) // this string is encoded within the output
138
+ testMetadata .Replacements ["__installationID__" ] = testMetadata .InstallationID
139
+ testMetadata .Replacements ["__customerID__" ] = testMetadata .CustomerID
140
+ testMetadata .Replacements ["__appSlug__" ] = testMetadata .AppSlug
141
+ testMetadata .Replacements ["__licenseID__" ] = testMetadata .LicenseID
139
142
140
143
ignoreEntitlementSig := map [string ][]string {
141
144
".ship/state.json" : {
@@ -146,7 +149,7 @@ var _ = Describe("ship init replicated.app/...", func() {
146
149
}
147
150
148
151
// compare the files in the temporary directory with those in the "expected" directory
149
- result , err := integration .CompareDir (path .Join (testPath , "expected" ), testOutputPath , replacements , []string {}, ignoreEntitlementSig )
152
+ result , err := integration .CompareDir (path .Join (testPath , "expected" ), testOutputPath , testMetadata . Replacements , []string {}, ignoreEntitlementSig )
150
153
Expect (err ).NotTo (HaveOccurred ())
151
154
Expect (result ).To (BeTrue ())
152
155
@@ -180,6 +183,10 @@ var _ = Describe("ship init replicated.app/...", func() {
180
183
// read the test metadata
181
184
testMetadata = readMetadata (testPath )
182
185
186
+ if testMetadata .Replacements == nil {
187
+ testMetadata .Replacements = make (map [string ]string )
188
+ }
189
+
183
190
close (done )
184
191
}, 20 )
185
192
@@ -202,19 +209,16 @@ var _ = Describe("ship init replicated.app/...", func() {
202
209
// copy the expected ship state to the output
203
210
// and run any replacements needed
204
211
205
- replacements := map [string ]string {
206
- // "__upstream__": strings.Replace(upstream, "&", "\\u0026", -1), // this string is encoded within the output
207
- "__installationID__" : testMetadata .InstallationID ,
208
- "__customerID__" : testMetadata .CustomerID ,
209
- "__appSlug__" : testMetadata .AppSlug ,
210
- "__licenseID__" : testMetadata .LicenseID ,
211
- }
212
+ testMetadata .Replacements ["__installationID__" ] = testMetadata .InstallationID
213
+ testMetadata .Replacements ["__customerID__" ] = testMetadata .CustomerID
214
+ testMetadata .Replacements ["__appSlug__" ] = testMetadata .AppSlug
215
+ testMetadata .Replacements ["__licenseID__" ] = testMetadata .LicenseID
212
216
213
217
readPath := filepath .Join (testPath , "expected" , ".ship" , "state.json" )
214
218
stateFile , err := ioutil .ReadFile (readPath )
215
219
Expect (err ).NotTo (HaveOccurred ())
216
220
217
- for k , v := range replacements {
221
+ for k , v := range testMetadata . Replacements {
218
222
stateFile = []byte (strings .Replace (string (stateFile ), k , v , - 1 ))
219
223
}
220
224
@@ -244,7 +248,7 @@ var _ = Describe("ship init replicated.app/...", func() {
244
248
}
245
249
246
250
// compare the files in the temporary directory with those in the "expected" directory
247
- result , err := integration .CompareDir (path .Join (testPath , "expected" ), testOutputPath , replacements , []string {}, ignoreEntitlementSig )
251
+ result , err := integration .CompareDir (path .Join (testPath , "expected" ), testOutputPath , testMetadata . Replacements , []string {}, ignoreEntitlementSig )
248
252
Expect (err ).NotTo (HaveOccurred ())
249
253
Expect (result ).To (BeTrue ())
250
254
}, 60 )
0 commit comments