@@ -127,6 +127,95 @@ func TestStepsWithParamAndGlobalParam(t *testing.T) {
127127 assert .Equal (t , wfv1 .WorkflowRunning , woc .wf .Status .Phase )
128128}
129129
130+ var stepsWithParam = `
131+ apiVersion: argoproj.io/v1alpha1
132+ kind: Workflow
133+ metadata:
134+ generateName: steps-with-params-
135+ spec:
136+ entrypoint: main
137+ templates:
138+ - name: main
139+ steps:
140+ - - name: use-with-param
141+ template: whalesay
142+ arguments:
143+ parameters:
144+ - name: message
145+ value: "{{item}}"
146+ withParam: "[1234, \"foo\\tbar\", true, []]"
147+ `
148+
149+ func TestExpandStepGroupWithParam (t * testing.T ) {
150+ ctx := logging .TestContext (t .Context ())
151+ wf := wfv1 .MustUnmarshalWorkflow (stepsWithParam )
152+ woc := newWoc (ctx , * wf )
153+
154+ expanded , err := woc .expandStepGroup (ctx , "[0]" , wf .Spec .Templates [0 ].Steps [0 ].Steps , & stepsContext {})
155+ require .NoError (t , err )
156+ require .Len (t , expanded , 4 )
157+
158+ expectedExpandedTasks := []struct {
159+ Name string
160+ Parameter string
161+ }{
162+ {
163+ Name : "use-with-param(0:1234)" ,
164+ Parameter : "1234" ,
165+ },
166+ {
167+ Name : `use-with-param(1:foo\tbar)` ,
168+ Parameter : "foo\t bar" ,
169+ },
170+ {
171+ Name : "use-with-param(2:true)" ,
172+ Parameter : "true" ,
173+ },
174+ {
175+ Name : "use-with-param(3:[])" ,
176+ Parameter : "[]" ,
177+ },
178+ }
179+
180+ for i , expected := range expectedExpandedTasks {
181+ assert .Equal (t , expected .Name , expanded [i ].Name )
182+ require .Len (t , expanded [i ].Arguments .Parameters , 1 )
183+ assert .Equal (t , expected .Parameter , expanded [i ].Arguments .Parameters [0 ].Value .String ())
184+ }
185+ }
186+
187+ var stepsWithItems = `
188+ apiVersion: argoproj.io/v1alpha1
189+ kind: Workflow
190+ metadata:
191+ generateName: steps-with-items-
192+ spec:
193+ entrypoint: main
194+ templates:
195+ - name: main
196+ steps:
197+ - - name: use-with-items
198+ template: whalesay
199+ arguments:
200+ parameters:
201+ - name: message
202+ value: "{{item}}"
203+ withItems:
204+ - Hello"Argo
205+ `
206+
207+ func TestExpandStepGroupWithItems (t * testing.T ) {
208+ ctx := logging .TestContext (t .Context ())
209+ wf := wfv1 .MustUnmarshalWorkflow (stepsWithItems )
210+ woc := newWoc (ctx , * wf )
211+
212+ expanded , err := woc .expandStepGroup (ctx , "[0]" , wf .Spec .Templates [0 ].Steps [0 ].Steps , & stepsContext {})
213+ require .NoError (t , err )
214+ require .Len (t , expanded , 1 )
215+
216+ assert .Equal (t , `Hello"Argo` , expanded [0 ].Arguments .Parameters [0 ].Value .String ())
217+ }
218+
130219func TestResourceDurationMetric (t * testing.T ) {
131220 nodeStatus := `
132221 boundaryID: many-items-z26lj
0 commit comments