runner

package
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2023 License: MIT Imports: 21 Imported by: 1

Documentation

Overview

Package runner responsible for excute the test case

Package runner provides the common expr style functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExprFuncSleep added in v0.0.12

func ExprFuncSleep(params ...interface{}) (res interface{}, err error)

ExprFuncSleep is a expr function for sleeping

Types

type ContextKey added in v0.0.12

type ContextKey string

ContextKey is the alias type of string for context key

func NewContextKeyBuilder added in v0.0.12

func NewContextKeyBuilder() ContextKey

NewContextKeyBuilder returns an emtpy context key

func (ContextKey) GetContextValueOrEmpty added in v0.0.12

func (c ContextKey) GetContextValueOrEmpty(ctx context.Context) string

GetContextValueOrEmpty returns the value of the context key, if not exist, return empty string

func (ContextKey) ParentDir added in v0.0.12

func (c ContextKey) ParentDir() ContextKey

ParentDir returns the key of the parsent directory

type FormatPrinter added in v0.0.9

type FormatPrinter interface {
	Fprintf(w io.Writer, level, format string, a ...any) (n int, err error)
}

FormatPrinter represents a formart printer with level

type LevelWriter added in v0.0.9

type LevelWriter interface {
	Info(format string, a ...any)
	Debug(format string, a ...any)
}

LevelWriter represents a writer with level

func NewDefaultLevelWriter added in v0.0.9

func NewDefaultLevelWriter(level string, writer io.Writer) LevelWriter

NewDefaultLevelWriter creates a default LevelWriter instance

type ReportRecord added in v0.0.4

type ReportRecord struct {
	Method    string
	API       string
	Body      string
	BeginTime time.Time
	EndTime   time.Time
	Error     error
}

ReportRecord represents the raw data of a HTTP request

func NewReportRecord added in v0.0.4

func NewReportRecord() *ReportRecord

NewReportRecord creates a record, and set the begin time to be now

func (*ReportRecord) Duration added in v0.0.4

func (r *ReportRecord) Duration() time.Duration

Duration returns the duration between begin and end time

func (*ReportRecord) ErrorCount added in v0.0.4

func (r *ReportRecord) ErrorCount() int

ErrorCount returns the count number of errors

func (*ReportRecord) GetErrorMessage added in v0.0.12

func (r *ReportRecord) GetErrorMessage() string

GetErrorMessage returns the error message

type ReportResult added in v0.0.4

type ReportResult struct {
	API              string
	Count            int
	Average          time.Duration
	Max              time.Duration
	Min              time.Duration
	QPS              int
	Error            int
	LastErrorMessage string
}

ReportResult represents the report result of a set of the same API requests

type ReportResultSlice added in v0.0.4

type ReportResultSlice []ReportResult

ReportResultSlice is the alias type of ReportResult slice

func (ReportResultSlice) Len added in v0.0.4

func (r ReportResultSlice) Len() int

Len returns the count of slice items

func (ReportResultSlice) Less added in v0.0.4

func (r ReportResultSlice) Less(i, j int) bool

Less returns if i bigger than j

func (ReportResultSlice) Swap added in v0.0.4

func (r ReportResultSlice) Swap(i, j int)

Swap swaps the items

type ReportResultWithTotal added in v0.0.4

type ReportResultWithTotal struct {
	ReportResult
	Total time.Duration
	First time.Time
	Last  time.Time
}

ReportResultWithTotal holds the total duration base on ReportResult

type ReportResultWriter added in v0.0.4

type ReportResultWriter interface {
	Output([]ReportResult) error
	WithAPIConverage(apiConverage apispec.APIConverage) ReportResultWriter
}

ReportResultWriter is the interface of the report writer

func NewDiscardResultWriter added in v0.0.4

func NewDiscardResultWriter() ReportResultWriter

NewDiscardResultWriter creates a report result writer which discard everything

func NewHTMLResultWriter added in v0.0.12

func NewHTMLResultWriter(writer io.Writer) ReportResultWriter

NewHTMLResultWriter creates a new htmlResultWriter

func NewMarkdownResultWriter added in v0.0.4

func NewMarkdownResultWriter(writer io.Writer) ReportResultWriter

NewMarkdownResultWriter creates the Markdown writer

func NewResultWriter added in v0.0.4

func NewResultWriter(writer io.Writer) ReportResultWriter

NewResultWriter creates a result writer with the specific io.Writer

type TestCaseRunner added in v0.0.4

type TestCaseRunner interface {
	RunTestCase(testcase *testing.TestCase, dataContext interface{}, ctx context.Context) (output interface{}, err error)
	WithOutputWriter(io.Writer) TestCaseRunner
	WithWriteLevel(level string) TestCaseRunner
	WithTestReporter(TestReporter) TestCaseRunner
	WithExecer(fakeruntime.Execer) TestCaseRunner
}

TestCaseRunner represents a test case runner

func NewSimpleTestCaseRunner added in v0.0.4

func NewSimpleTestCaseRunner() TestCaseRunner

NewSimpleTestCaseRunner creates the instance of the simple test case runner

type TestReporter added in v0.0.4

type TestReporter interface {
	PutRecord(*ReportRecord)
	GetAllRecords() []*ReportRecord
	ExportAllReportResults() (ReportResultSlice, error)
}

TestReporter is the interface of the report

func NewDiscardTestReporter added in v0.0.4

func NewDiscardTestReporter() TestReporter

NewDiscardTestReporter creates a test reporter which discard everything

func NewMemoryTestReporter added in v0.0.5

func NewMemoryTestReporter() TestReporter

NewMemoryTestReporter creates a memory based test reporter

Directories

Path Synopsis
Package kubernetes provides a low level client for small footprint consideration
Package kubernetes provides a low level client for small footprint consideration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL