Skip to content

Commit

Permalink
process: test case and suite totalSteps variables added to address o…
Browse files Browse the repository at this point in the history
…vh#808

Signed-off-by: Ivan Velasco <[email protected]>
  • Loading branch information
09bassOp committed Sep 2, 2024
1 parent aae6f3a commit 9f72887
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion process_testcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func (v *Venom) runTestCase(ctx context.Context, ts *TestSuite, tc *TestCase) {
tc.Vars = ts.Vars.Clone()
tc.Vars.Add("venom.testcase", tc.Name)
tc.Vars.AddAll(ts.ComputedVars)
tc.Vars.Add("venom.testcase.totalSteps", len(tc.RawTestSteps))
tc.computedVars = H{}

ctx = v.processSecrets(ctx, ts, tc)
Expand Down Expand Up @@ -185,10 +186,13 @@ func (v *Venom) runTestSteps(ctx context.Context, tc *TestCase, tsIn *TestStepRe
fromUserExecutor := tsIn != nil

loopRawTestSteps:
for stepNumber, rawStep := range tc.RawTestSteps {
for stepIndex, rawStep := range tc.RawTestSteps {
stepVars := tc.Vars.Clone()
stepVars.AddAll(previousStepVars)
stepVars.AddAllWithPrefix(tc.Name, tc.computedVars)

// Use stepNumber as a 1-based index
stepNumber := stepIndex + 1
stepVars.Add("venom.teststep.number", stepNumber)

ranged, err := parseRanged(ctx, rawStep, stepVars)
Expand Down
5 changes: 3 additions & 2 deletions process_testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ func (v *Venom) runTestSuite(ctx context.Context, ts *TestSuite) error {

totalSteps := 0
for _, tc := range ts.TestCases {
totalSteps += len(tc.testSteps)
totalSteps += len(tc.RawTestSteps)
}

ts.Vars.Add(("venom.testsuite.totalSteps"), totalSteps)
ts.Status = StatusRun
Info(ctx, "With secrets in testsuite")
for _, v := range ts.Secrets {
Expand Down Expand Up @@ -218,7 +219,7 @@ func (v *Venom) parseTestCases(ts *TestSuite) ([]string, []string, error) {
for i := range ts.TestCases {
tc := &ts.TestCases[i]
tc.originalName = tc.Name
tc.number = i
tc.number = i + 1
tc.Name = slug.Make(tc.Name)
tc.Vars = ts.Vars.Clone()
tc.Vars.Add("venom.testcase", tc.Name)
Expand Down

0 comments on commit 9f72887

Please sign in to comment.