(t *testing.T)
| 128 | } |
| 129 | |
| 130 | func TestNewFunctionScope(t *testing.T) { |
| 131 | t.Run("seeds args under SrcFnArg and declared variables", func(t *testing.T) { |
| 132 | s, err := NewFunctionScope( |
| 133 | []workflowapi.Variable{{Uid: "local", DataType: workflowapi.String, InitialValue: "init"}}, |
| 134 | map[string]expr.Value{"a": expr.IntVal(5)}, |
| 135 | ) |
| 136 | require.NoError(t, err) |
| 137 | |
| 138 | v, err := s.Resolve(workflowapi.Reference{SrcId: SrcFnArg, VarId: "a"}) |
| 139 | require.NoError(t, err) |
| 140 | assert.Equal(t, expr.IntVal(5), v) |
| 141 | |
| 142 | v, err = s.Resolve(workflowapi.Reference{SrcId: SrcDeclared, VarId: "local"}) |
| 143 | require.NoError(t, err) |
| 144 | assert.Equal(t, expr.StringVal("init"), v) |
| 145 | }) |
| 146 | |
| 147 | t.Run("declared variable seeding error propagates", func(t *testing.T) { |
| 148 | _, err := NewFunctionScope( |
| 149 | []workflowapi.Variable{{Uid: "bad", DataType: workflowapi.Int, InitialValue: "nope"}}, |
| 150 | nil, |
| 151 | ) |
| 152 | require.Error(t, err) |
| 153 | }) |
| 154 | } |
| 155 | |
| 156 | func TestApplyOutput(t *testing.T) { |
| 157 | t.Run("inactive binding writes nothing", func(t *testing.T) { |
nothing calls this directly
no test coverage detected