MCPcopy
hub / github.com/nektos/act / TestEvaluateStep

Function TestEvaluateStep

pkg/runner/expression_test.go:155–192  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

153}
154
155func 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
194func TestInterpolate(t *testing.T) {
195 rc := &RunContext{

Callers

nothing calls this directly

Calls 5

createRunContextFunction · 0.85
evaluateMethod · 0.65
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…