Skip to content

Commit

Permalink
start working on cleaning up the output in yml , xml and json
Browse files Browse the repository at this point in the history
Signed-off-by: Fokion Sotiropoulos <[email protected]>
  • Loading branch information
fokion committed May 17, 2023
1 parent 5518a07 commit 1294c0c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
19 changes: 11 additions & 8 deletions process_testcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,25 @@ func (v *Venom) runTestCase(ctx context.Context, ts *TestSuite, tc *TestCase) {
tc.Vars.AddAll(ts.ComputedVars)
tc.computedVars = H{}

computedSecrets := []string{}
ctx = v.processSecrets(ctx, ts, tc)

Info(ctx, "Starting testcase")

defer Info(ctx, "Ending testcase")
// ##### RUN Test Steps Here
v.runTestSteps(ctx, tc, nil)
}

func (v *Venom) processSecrets(ctx context.Context, ts *TestSuite, tc *TestCase) context.Context {
computedSecrets := []string{}
for k, v := range tc.Vars {
for _, s := range ts.Secrets {
if strings.Compare(k, s) == 0 {
computedSecrets = append(computedSecrets, fmt.Sprint(v))
}
}
}
ctx = context.WithValue(ctx, ContextKey("secrets"), computedSecrets)

Info(ctx, "Starting testcase")

defer Info(ctx, "Ending testcase")
// ##### RUN Test Steps Here
v.runTestSteps(ctx, tc, nil)
return context.WithValue(ctx, ContextKey("secrets"), computedSecrets)
}

func (v *Venom) runTestSteps(ctx context.Context, tc *TestCase, tsIn *TestStepResult) {
Expand Down
18 changes: 18 additions & 0 deletions venom_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package venom

import (
"bytes"
"context"
"encoding/json"
"encoding/xml"
"fmt"
Expand All @@ -23,6 +24,23 @@ func init() {
}
}

func (v *Venom) CleanUpSecrets(testSuite *TestSuite) *TestSuite {
for _, testCase := range testSuite.TestCases {
ctx := v.processSecrets(context.Background(), testSuite, &testCase)
for _, result := range testCase.TestStepResults {
for i, v := range result.ComputedVars {
result.ComputedVars[i] = HideSensitive(ctx, v)
}
for i, v := range result.InputVars {
result.ComputedVars[i] = HideSensitive(ctx, v)
}
result.Systemout = HideSensitive(ctx, result.Systemout)
result.Systemerr = HideSensitive(ctx, result.Systemerr)
}
}
return testSuite
}

// OutputResult output result to sdtout, files...
func (v *Venom) OutputResult() error {
if v.OutputDir == "" {
Expand Down

0 comments on commit 1294c0c

Please sign in to comment.