github.com/kubeshop/testkube@v1.17.23/contrib/executor/tracetest/pkg/model/result.go (about)

     1  package model
     2  
     3  import (
     4  	"strings"
     5  
     6  	"github.com/kubeshop/testkube/pkg/api/v1/testkube"
     7  )
     8  
     9  const (
    10  	PASSED_TEST_ICON = "✔"
    11  	FAILED_TEST_ICON = "✘"
    12  )
    13  
    14  type Result struct {
    15  	Output         string
    16  	ServerEndpoint string
    17  	OutputEndpoint string
    18  }
    19  
    20  func (r *Result) GetOutput() string {
    21  	if r.OutputEndpoint != "" {
    22  		return strings.ReplaceAll(r.Output, r.ServerEndpoint, r.OutputEndpoint)
    23  	}
    24  	return r.Output
    25  }
    26  
    27  func (r *Result) ToSuccessfulExecutionResult() testkube.ExecutionResult {
    28  	return testkube.ExecutionResult{
    29  		Output: r.GetOutput(),
    30  		Status: testkube.ExecutionStatusPassed,
    31  	}
    32  }
    33  
    34  func (r *Result) ToFailedExecutionResult(err error) testkube.ExecutionResult {
    35  	return testkube.ExecutionResult{
    36  		ErrorMessage: r.GetOutput(),
    37  		Output:       r.GetOutput(),
    38  		Status:       testkube.ExecutionStatusFailed,
    39  	}
    40  }