Skip to content

Commit

Permalink
fix: added test for expandTask function
Browse files Browse the repository at this point in the history
Signed-off-by: Isitha Subasinghe <isitha@pipekit.io>
  • Loading branch information
isubasinghe committed Aug 13, 2023
1 parent ec16322 commit 0774e6a
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions workflow/controller/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2260,7 +2260,7 @@ func TestExpandWithItems(t *testing.T) {
wf, err := wfcset.Create(ctx, wf, metav1.CreateOptions{})
assert.NoError(t, err)
woc := newWorkflowOperationCtx(wf, controller)
newSteps, err := woc.expandStep(wf.Spec.Templates[0].Steps[0].Steps[0])
newSteps, err := woc.expandStepLazy(wf.Spec.Templates[0].Steps[0].Steps[0], true)
assert.NoError(t, err)
assert.Equal(t, 5, len(newSteps))
woc.operate(ctx)
Expand All @@ -2269,6 +2269,26 @@ func TestExpandWithItems(t *testing.T) {
assert.Equal(t, 5, len(pods.Items))
}

func TestNoMustExpandWithItems(t *testing.T) {
cancel, controller := newController()
defer cancel()
wfcset := controller.wfclientset.ArgoprojV1alpha1().Workflows("")

// Test list expansion
ctx := context.Background()
wf := wfv1.MustUnmarshalWorkflow(expandWithItems)
wf, err := wfcset.Create(ctx, wf, metav1.CreateOptions{})
assert.NoError(t, err)
woc := newWorkflowOperationCtx(wf, controller)
newSteps, err := woc.expandStepLazy(wf.Spec.Templates[0].Steps[0].Steps[0], false)
assert.NoError(t, err)
assert.Equal(t, 0, len(newSteps))
woc.operate(ctx)
pods, err := listPods(woc)
assert.NoError(t, err)
assert.Equal(t, 0, len(pods.Items))
}

var expandWithItemsMap = `
apiVersion: argoproj.io/v1alpha1
kind: Workflow
Expand Down Expand Up @@ -2310,7 +2330,7 @@ func TestExpandWithItemsMap(t *testing.T) {
wf, err := wfcset.Create(ctx, wf, metav1.CreateOptions{})
assert.NoError(t, err)
woc := newWorkflowOperationCtx(wf, controller)
newSteps, err := woc.expandStep(wf.Spec.Templates[0].Steps[0].Steps[0])
newSteps, err := woc.expandStepLazy(wf.Spec.Templates[0].Steps[0].Steps[0], true)
assert.NoError(t, err)
assert.Equal(t, 3, len(newSteps))
assert.Equal(t, "debian 9.1 JSON({\"os\":\"debian\",\"version\":9.1})", newSteps[0].Arguments.Parameters[0].Value.String())
Expand Down

0 comments on commit 0774e6a

Please sign in to comment.