Skip to content

Commit

Permalink
fix: Unit test TestNewOperation order of pipeline execution maybe dif…
Browse files Browse the repository at this point in the history
…ferent to order of submit (#7069)

Signed-off-by: Tianchu Zhao <evantczhao@gmail.com>
  • Loading branch information
tczhao committed Oct 26, 2021
1 parent 18c953d commit 31bf57b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions server/event/dispatch/operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dispatch
import (
"context"
"encoding/json"
"sort"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -153,18 +154,22 @@ func TestNewOperation(t *testing.T) {

expectedParamValues := []string{
"bar",
`{"bar":"baz"}`,
"bar",
`{"bar":"baz"}`,
}
var paramValues []string
// assert
list, err := client.ArgoprojV1alpha1().Workflows("my-ns").List(ctx, metav1.ListOptions{})
if assert.NoError(t, err) && assert.Len(t, list.Items, 3) {
for i, wf := range list.Items {
for _, wf := range list.Items {
assert.Equal(t, "my-instanceid", wf.Labels[common.LabelKeyControllerInstanceID])
assert.Equal(t, "my-sub", wf.Labels[common.LabelKeyCreator])
assert.Contains(t, wf.Labels, common.LabelKeyWorkflowEventBinding)
assert.Equal(t, []wfv1.Parameter{{Name: "my-param", Value: wfv1.AnyStringPtr(expectedParamValues[i])}}, wf.Spec.Arguments.Parameters)
assert.Contains(t, "my-param", wf.Spec.Arguments.Parameters[0].Name)
paramValues = append(paramValues, string(*wf.Spec.Arguments.Parameters[0].Value))
}
sort.Strings(paramValues)
assert.Equal(t, expectedParamValues, paramValues)
}
assert.Equal(t, "Warning WorkflowEventBindingError failed to dispatch event: failed to evaluate workflow template expression: unexpected token EOF (1:1)", <-recorder.Events)
assert.Equal(t, "Warning WorkflowEventBindingError failed to dispatch event: failed to get workflow template: workflowtemplates.argoproj.io \"not-found\" not found", <-recorder.Events)
Expand Down

0 comments on commit 31bf57b

Please sign in to comment.