github.com/kubeshop/testkube@v1.17.23/pkg/repository/result/interface.go (about)

     1  package result
     2  
     3  import (
     4  	"context"
     5  	"io"
     6  	"time"
     7  
     8  	"github.com/kubeshop/testkube/pkg/api/v1/testkube"
     9  )
    10  
    11  const PageDefaultLimit int = 100
    12  
    13  type Filter interface {
    14  	TestName() string
    15  	TestNameDefined() bool
    16  	LastNDays() int
    17  	LastNDaysDefined() bool
    18  	StartDate() time.Time
    19  	StartDateDefined() bool
    20  	EndDate() time.Time
    21  	EndDateDefined() bool
    22  	Statuses() testkube.ExecutionStatuses
    23  	StatusesDefined() bool
    24  	Page() int
    25  	PageSize() int
    26  	TextSearchDefined() bool
    27  	TextSearch() string
    28  	Selector() string
    29  	TypeDefined() bool
    30  	Type() string
    31  }
    32  
    33  //go:generate mockgen -destination=./mock_repository.go -package=result "github.com/kubeshop/testkube/pkg/repository/result" Repository
    34  type Repository interface {
    35  	Sequences
    36  	// Get gets execution result by id or name
    37  	Get(ctx context.Context, id string) (testkube.Execution, error)
    38  	// Get gets execution result without output
    39  	GetExecution(ctx context.Context, id string) (testkube.Execution, error)
    40  	// GetByNameAndTest gets execution result by name and test name
    41  	GetByNameAndTest(ctx context.Context, name, testName string) (testkube.Execution, error)
    42  	// GetLatestByTest gets latest execution result by test
    43  	GetLatestByTest(ctx context.Context, testName string) (*testkube.Execution, error)
    44  	// GetLatestByTests gets latest execution results by test names
    45  	GetLatestByTests(ctx context.Context, testNames []string) (executions []testkube.Execution, err error)
    46  	// GetExecutions gets executions using a filter, use filter with no data for all
    47  	GetExecutions(ctx context.Context, filter Filter) ([]testkube.Execution, error)
    48  	// GetExecutionTotals gets the statistics on number of executions using a filter, but without paging
    49  	GetExecutionTotals(ctx context.Context, paging bool, filter ...Filter) (result testkube.ExecutionsTotals, err error)
    50  	// Insert inserts new execution result
    51  	Insert(ctx context.Context, result testkube.Execution) error
    52  	// Update updates execution result
    53  	Update(ctx context.Context, result testkube.Execution) error
    54  	// UpdateResult updates result in execution
    55  	UpdateResult(ctx context.Context, id string, execution testkube.Execution) error
    56  	// StartExecution updates execution start time
    57  	StartExecution(ctx context.Context, id string, startTime time.Time) error
    58  	// EndExecution updates execution end time
    59  	EndExecution(ctx context.Context, execution testkube.Execution) error
    60  	// GetLabels get all available labels
    61  	GetLabels(ctx context.Context) (labels map[string][]string, err error)
    62  	// DeleteByTest deletes execution results by test
    63  	DeleteByTest(ctx context.Context, testName string) error
    64  	// DeleteByTestSuite deletes execution results by test suite
    65  	DeleteByTestSuite(ctx context.Context, testSuiteName string) error
    66  	// DeleteAll deletes all execution results
    67  	DeleteAll(ctx context.Context) error
    68  	// DeleteByTests deletes execution results by tests
    69  	DeleteByTests(ctx context.Context, testNames []string) (err error)
    70  	// DeleteByTestSuites deletes execution results by test suites
    71  	DeleteByTestSuites(ctx context.Context, testSuiteNames []string) (err error)
    72  	// DeleteForAllTestSuites deletes execution results for all test suites
    73  	DeleteForAllTestSuites(ctx context.Context) (err error)
    74  	// GetTestMetrics returns metrics for test
    75  	GetTestMetrics(ctx context.Context, name string, limit, last int) (metrics testkube.ExecutionsMetrics, err error)
    76  	// Count returns executions count
    77  	Count(ctx context.Context, filter Filter) (int64, error)
    78  }
    79  
    80  type Sequences interface {
    81  	// GetNextExecutionNumber gets next execution number by test name
    82  	GetNextExecutionNumber(ctx context.Context, testName string) (number int32, err error)
    83  }
    84  
    85  //go:generate mockgen -destination=./mock_output_repository.go -package=result "github.com/kubeshop/testkube/pkg/repository/result" OutputRepository
    86  type OutputRepository interface {
    87  	// GetOutput gets execution output by id or name
    88  	GetOutput(ctx context.Context, id, testName, testSuiteName string) (output string, err error)
    89  	// InsertOutput inserts new execution output
    90  	InsertOutput(ctx context.Context, id, testName, testSuiteName, output string) error
    91  	// UpdateOutput updates execution output
    92  	UpdateOutput(ctx context.Context, id, testName, testSuiteName, output string) error
    93  	// DeleteOutput deletes execution output
    94  	DeleteOutput(ctx context.Context, id, testName, testSuiteName string) error
    95  	// DeleteOutputByTest deletes execution output by test
    96  	DeleteOutputByTest(ctx context.Context, testName string) error
    97  	// DeleteOutputForTests deletes execution output for tests
    98  	DeleteOutputForTests(ctx context.Context, testNames []string) error
    99  	// DeleteOutputByTestSuite deletes execution output by test suite
   100  	DeleteOutputByTestSuite(ctx context.Context, testSuiteName string) error
   101  	// DeleteOutputForTestSuites deletes execution output for test suites
   102  	DeleteOutputForTestSuites(ctx context.Context, testSuiteNames []string) error
   103  	// DeleteAllOutput deletes all execution output
   104  	DeleteAllOutput(ctx context.Context) error
   105  	// DeleteOutputForAllTestSuite deletes all execution output for test suite
   106  	DeleteOutputForAllTestSuite(ctx context.Context) error
   107  	// StreamOutput streams execution output by id or name
   108  	StreamOutput(ctx context.Context, executionID, testName, testSuiteName string) (reader io.Reader, err error)
   109  	// GetOutputSize gets execution output metadata by id or name
   110  	GetOutputSize(ctx context.Context, executionID, testName, testSuiteName string) (size int, err error)
   111  }