@@ -13,6 +13,7 @@ var manifestfile1 = "../../dat/manifest1.yaml"
13
13
var manifestfile3 = "../../dat/manifest3.yaml"
14
14
var manifestfile4 = "../../dat/manifest4.yaml"
15
15
var manifestfile5 = "../../dat/manifest5.yaml"
16
+ var manifestfile6 = "../../dat/manifest6.yaml"
16
17
var testfile1 = "../../dat/deploy1.yaml"
17
18
var testfile2 = "../../dat/deploy2.yaml"
18
19
var testfile3 = "../../dat/deploy3.yaml"
@@ -131,6 +132,74 @@ func TestParseManifestYAML_feed(t *testing.T) {
131
132
}
132
133
}
133
134
135
+ func TestParseManifestYAML_param (t * testing.T ) {
136
+ data , err := ioutil .ReadFile (manifestfile6 )
137
+ if err != nil {
138
+ panic (err )
139
+ }
140
+
141
+ var manifest parsers.ManifestYAML
142
+ err = parsers .NewYAMLParser ().Unmarshal (data , & manifest )
143
+ if err != nil {
144
+ panic (err )
145
+ }
146
+
147
+ assert .Equal (t , 1 , len (manifest .Package .Actions ), "Get action list failed." )
148
+ for action_name := range manifest .Package .Actions {
149
+ var action = manifest .Package .Actions [action_name ]
150
+ switch action_name {
151
+ case "action1" :
152
+ for param_name := range action .Inputs {
153
+ var param = action .Inputs [param_name ]
154
+ switch param_name {
155
+ case "inline1" :
156
+ assert .Equal (t , "{ \" key\" : true }" , param .Value , "Get param value failed." )
157
+ case "inline2" :
158
+ assert .Equal (t , "Just a string" , param .Value , "Get param value failed." )
159
+ case "inline3" :
160
+ assert .Equal (t , nil , param .Value , "Get param value failed." )
161
+ case "inline4" :
162
+ assert .Equal (t , true , param .Value , "Get param value failed." )
163
+ case "inline5" :
164
+ assert .Equal (t , 42 , param .Value , "Get param value failed." )
165
+ case "inline6" :
166
+ assert .Equal (t , - 531 , param .Value , "Get param value failed." )
167
+ case "inline7" :
168
+ assert .Equal (t , 432.432E-43 , param .Value , "Get param value failed." )
169
+ case "inline8" :
170
+ assert .Equal (t , "[ true, null, \" boo\" , { \" key\" : 0 }]" , param .Value , "Get param value failed." )
171
+ case "inline9" :
172
+ assert .Equal (t , false , param .Value , "Get param value failed." )
173
+ case "inline0" :
174
+ assert .Equal (t , 456.423 , param .Value , "Get param value failed." )
175
+ case "inlin10" :
176
+ assert .Equal (t , nil , param .Value , "Get param value failed." )
177
+ case "inlin11" :
178
+ assert .Equal (t , true , param .Value , "Get param value failed." )
179
+ case "expand1" :
180
+ assert .Equal (t , nil , param .Value , "Get param value failed." )
181
+ case "expand2" :
182
+ assert .Equal (t , true , param .Value , "Get param value failed." )
183
+ case "expand3" :
184
+ assert .Equal (t , false , param .Value , "Get param value failed." )
185
+ case "expand4" :
186
+ assert .Equal (t , 15646 , param .Value , "Get param value failed." )
187
+ case "expand5" :
188
+ assert .Equal (t , "{ \" key\" : true }" , param .Value , "Get param value failed." )
189
+ case "expand6" :
190
+ assert .Equal (t , "[ true, null, \" boo\" , { \" key\" : 0 }]" , param .Value , "Get param value failed." )
191
+ case "expand7" :
192
+ assert .Equal (t , nil , param .Value , "Get param value failed." )
193
+ default :
194
+ t .Error ("Get param name failed" )
195
+ }
196
+ }
197
+ default :
198
+ t .Error ("Get action name failed" )
199
+ }
200
+ }
201
+ }
202
+
134
203
func TestParseDeploymentYAML_Application (t * testing.T ) {
135
204
//var deployment utils.DeploymentYAML
136
205
mm := parsers .NewYAMLParser ()
@@ -158,8 +227,8 @@ func TestParseDeploymentYAML_Package(t *testing.T) {
158
227
assert .Equal (t , "12345678ABCDEF" , pkg .Credential , "Get package credential failed." )
159
228
assert .Equal (t , 1 , len (pkg .Inputs ), "Get package input list failed." )
160
229
//get and verify inputs
161
- for param_name , value := range pkg .Inputs {
162
- assert .Equal (t , "value" , value , "Get input value failed." )
230
+ for param_name , param := range pkg .Inputs {
231
+ assert .Equal (t , "value" , param . Value , "Get input value failed." )
163
232
assert .Equal (t , "param" , param_name , "Get input param name failed." )
164
233
}
165
234
}
@@ -179,11 +248,11 @@ func TestParseDeploymentYAML_Action(t *testing.T) {
179
248
assert .Equal (t , "12345678ABCDEF" , action .Credential , "Get action credential failed." )
180
249
assert .Equal (t , 1 , len (action .Inputs ), "Get package input list failed." )
181
250
//get and verify inputs
182
- for param_name , value := range action .Inputs {
183
- switch value .(type ) {
251
+ for param_name , param := range action .Inputs {
252
+ switch param . Value .(type ) {
184
253
case string :
185
254
assert .Equal (t , "name" , param_name , "Get input param name failed." )
186
- assert .Equal (t , "Bernie" , value , "Get input value failed." )
255
+ assert .Equal (t , "Bernie" , param . Value , "Get input value failed." )
187
256
default :
188
257
t .Error ("Get input value type failed." )
189
258
}
0 commit comments