@@ -7,6 +7,57 @@ import (
7
7
"testing"
8
8
)
9
9
10
+ func TestWorkflowNodeVariables_GetVariable (t * testing.T ) {
11
+ variableList := workflowmodel.WorkflowNodeVariables {
12
+ Path : "/meso_post/00/initial" ,
13
+ VariableList : []workflowmodel.NodeVariable {
14
+ {
15
+ Name : "BASE_DIR" ,
16
+ Value : "/g1/u/nwp_pd/ecfworks/meso_post" ,
17
+ Type : workflowmodel .Variable ,
18
+ },
19
+ {
20
+ Name : "BIN_DIR" ,
21
+ Value : "/g1/u/nwp_pd/MESO_POST/bin" ,
22
+ Type : workflowmodel .Variable ,
23
+ },
24
+ {
25
+ Name : "ECF_DATE" ,
26
+ Value : "20190316" ,
27
+ Type : workflowmodel .Variable ,
28
+ },
29
+ },
30
+ GeneratedVariableList : []workflowmodel.NodeVariable {
31
+ {
32
+ Name : "ECF_NAME" ,
33
+ Value : "/meso_post/00/initial" ,
34
+ Type : workflowmodel .GeneratedVariable ,
35
+ },
36
+ {
37
+ Name : "ECF_DATE" ,
38
+ Value : "20190315" ,
39
+ Type : workflowmodel .Variable ,
40
+ },
41
+ },
42
+ }
43
+
44
+ tests := []struct {
45
+ name string
46
+ expectedValue string
47
+ }{
48
+ {"BASE_DIR" , "/g1/u/nwp_pd/ecfworks/meso_post" },
49
+ {"BIN_DIR" , "/g1/u/nwp_pd/MESO_POST/bin" },
50
+ {"ECF_DATE" , "20190316" },
51
+ {"ECF_NAME" , "/meso_post/00/initial" },
52
+ }
53
+ for _ , test := range tests {
54
+ variable := variableList .GetVariable (test .name )
55
+ if variable .Value != test .expectedValue {
56
+ t .Errorf ("%s = %s, expected %s" , test .name , variable .Value , test .expectedValue )
57
+ }
58
+ }
59
+ }
60
+
10
61
func TestWorkflowNodeVariables_JSON (t * testing.T ) {
11
62
vars := workflowmodel.WorkflowNodeVariables {
12
63
Path : "/meso_post/00/initial" ,
@@ -122,3 +173,91 @@ func TestWorkflowNode_JSON(t *testing.T) {
122
173
fmt .Printf ("json.Marshal(node) = %s\n " , nodeJsonString )
123
174
124
175
}
176
+
177
+ func TestWorkflowNode_GetVariable (t * testing.T ) {
178
+ node := workflowmodel.WorkflowNode {
179
+ Name : "initial" ,
180
+ Status : workflowmodel .Queued ,
181
+ Type : workflowmodel .Task ,
182
+ VariableList : workflowmodel.WorkflowNodeVariables {
183
+ Path : "/meso_post/00/initial" ,
184
+ VariableList : []workflowmodel.NodeVariable {
185
+ {
186
+ Name : "BASE_DIR" ,
187
+ Value : "/g1/u/nwp_pd/ecfworks/meso_post" ,
188
+ Type : workflowmodel .Variable ,
189
+ },
190
+ {
191
+ Name : "BIN_DIR" ,
192
+ Value : "/g1/u/nwp_pd/MESO_POST/bin" ,
193
+ Type : workflowmodel .Variable ,
194
+ },
195
+ },
196
+ GeneratedVariableList : []workflowmodel.NodeVariable {
197
+ {
198
+ Name : "ECF_NAME" ,
199
+ Value : "/meso_post/00/initial" ,
200
+ Type : workflowmodel .GeneratedVariable ,
201
+ },
202
+ },
203
+ },
204
+ InheritedVariableList : []workflowmodel.WorkflowNodeVariables {
205
+ {
206
+ Path : "/meso_post/00" ,
207
+ VariableList : []workflowmodel.NodeVariable {
208
+ {
209
+ Name : "HH" ,
210
+ Value : "00" ,
211
+ Type : workflowmodel .Variable ,
212
+ },
213
+ },
214
+ GeneratedVariableList : []workflowmodel.NodeVariable {
215
+ {
216
+ Name : "ECF_NAME" ,
217
+ Value : "/meso_post/00" ,
218
+ Type : workflowmodel .GeneratedVariable ,
219
+ },
220
+ },
221
+ },
222
+ {
223
+ Path : "/meso_post" ,
224
+ VariableList : []workflowmodel.NodeVariable {
225
+ {
226
+ Name : "SUITE" ,
227
+ Value : "meso_post" ,
228
+ Type : workflowmodel .Variable ,
229
+ },
230
+ },
231
+ GeneratedVariableList : []workflowmodel.NodeVariable {
232
+ {
233
+ Name : "ECF_NAME" ,
234
+ Value : "/meso_post" ,
235
+ Type : workflowmodel .GeneratedVariable ,
236
+ },
237
+ {
238
+ Name : "ECF_DATE" ,
239
+ Value : "20190312" ,
240
+ Type : workflowmodel .GeneratedVariable ,
241
+ },
242
+ },
243
+ },
244
+ },
245
+ }
246
+
247
+ tests := []struct {
248
+ name string
249
+ expectedValue string
250
+ }{
251
+ {"ECF_NAME" , "/meso_post/00/initial" },
252
+ {"SUITE" , "meso_post" },
253
+ {"HH" , "00" },
254
+ {"BASE_DIR" , "/g1/u/nwp_pd/ecfworks/meso_post" },
255
+ }
256
+
257
+ for _ , test := range tests {
258
+ variable := node .GetVariable (test .name )
259
+ if variable .Value != test .expectedValue {
260
+ t .Errorf ("%s = %s, expected %s" , test .name , variable .Value , test .expectedValue )
261
+ }
262
+ }
263
+ }
0 commit comments