github.com/kubeshop/testkube@v1.17.23/cmd/kubectl-testkube/commands/testsuites/renderer/execution_obj.go (about)

     1  package renderer
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  
     7  	"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/common/render"
     8  	"github.com/kubeshop/testkube/pkg/api/v1/client"
     9  	"github.com/kubeshop/testkube/pkg/api/v1/testkube"
    10  	"github.com/kubeshop/testkube/pkg/ui"
    11  )
    12  
    13  func TestSuiteExecutionRenderer(client client.Client, ui *ui.UI, obj interface{}) error {
    14  	execution, ok := obj.(testkube.TestSuiteExecution)
    15  	if !ok {
    16  		return fmt.Errorf("can't render execution, expecrted obj to be testkube.Execution but got '%T'", obj)
    17  	}
    18  
    19  	ui.Warn("Id:      ", execution.Id)
    20  	ui.Warn("Name:    ", execution.Name)
    21  	if execution.Status != nil {
    22  		ui.Warn("Status:  ", string(*execution.Status))
    23  	}
    24  	ui.Warn("Duration:", execution.CalculateDuration().String()+"\n")
    25  	ui.Warn("Labels:  ", testkube.MapToString(execution.Labels))
    26  	if execution.RunningContext != nil {
    27  		ui.Warn("Running context:")
    28  		ui.Warn("Type:   ", execution.RunningContext.Type_)
    29  		ui.Warn("Context:", execution.RunningContext.Context)
    30  	}
    31  
    32  	info, err := client.GetServerInfo()
    33  	ui.ExitOnError("getting server info", err)
    34  
    35  	render.PrintTestSuiteExecutionURIs(&execution, info.DashboardUri)
    36  
    37  	ui.Table(execution, os.Stdout)
    38  
    39  	ui.NL()
    40  
    41  	return nil
    42  }