Skip to content

Commit

Permalink
fix: remove code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
vsukhin committed Oct 30, 2023
1 parent 7a9b71d commit 838fbe1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions contrib/executor/cypress/pkg/runner/cypress.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,7 @@ func (r *CypressRunner) Run(ctx context.Context, execution testkube.Execution) (
suites, serr = junit.IngestDir(junitReportDir)
result = MapJunitToExecutionResults(out, suites)
} else {
status := testkube.PASSED_ExecutionStatus
result.Status = &status
result.Output = string(out)
result.OutputType = "text/plain"
result = makeSuccessExecution(out)
}

output.PrintLogf("%s Mapped Junit to Execution Results...", ui.IconCheckMark)
Expand Down Expand Up @@ -282,12 +279,18 @@ func (r *CypressRunner) Validate(execution testkube.Execution) error {
return nil
}

func MapJunitToExecutionResults(out []byte, suites []junit.Suite) (result testkube.ExecutionResult) {
func makeSuccessExecution(out []byte) (result testkube.ExecutionResult) {
status := testkube.PASSED_ExecutionStatus
result.Status = &status
result.Output = string(out)
result.OutputType = "text/plain"

return result
}

func MapJunitToExecutionResults(out []byte, suites []junit.Suite) (result testkube.ExecutionResult) {
result = makeSuccessExecution(out)

for _, suite := range suites {
for _, test := range suite.Tests {

Expand Down

0 comments on commit 838fbe1

Please sign in to comment.