(t *testing.T)
| 153 | } |
| 154 | |
| 155 | func TestEvaluateStep(t *testing.T) { |
| 156 | rc := createRunContext(t) |
| 157 | step := &stepRun{ |
| 158 | RunContext: rc, |
| 159 | } |
| 160 | |
| 161 | ee := rc.NewStepExpressionEvaluator(context.Background(), step) |
| 162 | |
| 163 | tables := []struct { |
| 164 | in string |
| 165 | out interface{} |
| 166 | errMesg string |
| 167 | }{ |
| 168 | {"steps.idwithnothing.conclusion", model.StepStatusSuccess.String(), ""}, |
| 169 | {"steps.idwithnothing.outcome", model.StepStatusFailure.String(), ""}, |
| 170 | {"steps.idwithnothing.outputs.foowithnothing", "barwithnothing", ""}, |
| 171 | {"steps.id-with-hyphens.conclusion", model.StepStatusSuccess.String(), ""}, |
| 172 | {"steps.id-with-hyphens.outcome", model.StepStatusFailure.String(), ""}, |
| 173 | {"steps.id-with-hyphens.outputs.foo-with-hyphens", "bar-with-hyphens", ""}, |
| 174 | {"steps.id_with_underscores.conclusion", model.StepStatusSuccess.String(), ""}, |
| 175 | {"steps.id_with_underscores.outcome", model.StepStatusFailure.String(), ""}, |
| 176 | {"steps.id_with_underscores.outputs.foo_with_underscores", "bar_with_underscores", ""}, |
| 177 | } |
| 178 | |
| 179 | for _, table := range tables { |
| 180 | t.Run(table.in, func(t *testing.T) { |
| 181 | assertObject := assert.New(t) |
| 182 | out, err := ee.evaluate(context.Background(), table.in, exprparser.DefaultStatusCheckNone) |
| 183 | if table.errMesg == "" { |
| 184 | assertObject.NoError(err, table.in) |
| 185 | assertObject.Equal(table.out, out, table.in) |
| 186 | } else { |
| 187 | assertObject.Error(err, table.in) |
| 188 | assertObject.Equal(table.errMesg, err.Error(), table.in) |
| 189 | } |
| 190 | }) |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | func TestInterpolate(t *testing.T) { |
| 195 | rc := &RunContext{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…