github.com/kubeshop/testkube@v1.17.23/contrib/executor/jmeter/pkg/runner/runner_test.go (about)

     1  package runner
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  
     8  	"github.com/kubeshop/testkube/contrib/executor/jmeter/pkg/parser"
     9  	"github.com/kubeshop/testkube/pkg/api/v1/testkube"
    10  )
    11  
    12  func TestMapStatus(t *testing.T) {
    13  	t.Parallel()
    14  
    15  	t.Run("should map valid status", func(t *testing.T) {
    16  		t.Parallel()
    17  
    18  		out := MapResultStatus(parser.Result{Success: false})
    19  		assert.Equal(t, out, string(testkube.FAILED_ExecutionStatus))
    20  	})
    21  
    22  	t.Run("should map invalid status", func(t *testing.T) {
    23  		t.Parallel()
    24  
    25  		out := MapResultStatus(parser.Result{Success: true})
    26  		assert.Equal(t, out, string(testkube.PASSED_ExecutionStatus))
    27  	})
    28  
    29  }
    30  
    31  func TestMapResultsToExecutionResults(t *testing.T) {
    32  	t.Parallel()
    33  
    34  	t.Run("results are mapped to execution results", func(t *testing.T) {
    35  		t.Parallel()
    36  
    37  		out := []byte("log output")
    38  		results := parser.Results{
    39  			HasError:         true,
    40  			LastErrorMessage: "some error",
    41  			Results: []parser.Result{
    42  				{
    43  					Success: false,
    44  					Error:   "some error",
    45  				},
    46  			},
    47  		}
    48  
    49  		result := MapResultsToExecutionResults(out, results)
    50  
    51  		assert.Equal(t, "log output", result.Output)
    52  		assert.Equal(t, "some error", result.ErrorMessage)
    53  	})
    54  }