test

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultObjectCheckForOperation

func DefaultObjectCheckForOperation(op driver.ObjectOperationType) *ast.Module

DefaultObjectCheckForOperation returns a built-in default check for applying Kubernetes objects.

func Run

func Run(testDoc *doc.Document, opts ...RunOpt) error

Run executes a test document.

nolint(gocognit)

Types

type Closer

type Closer interface {
	Close()
}

Closer is an interface that closes an implicit test tracking entity.

type CloserFunc

type CloserFunc func()

CloserFunc is a Closer adaptor. This adaptor can be used with nil function pointers.

func (CloserFunc) Close

func (c CloserFunc) Close()

Close implements Closer.

type Document

type Document struct {
	Description string
	Properties  map[string]interface{}
	Steps       []*Step
}

Document records the execution of a test document.

func (*Document) EachResult

func (d *Document) EachResult(f func(*Step, *result.Result))

EachResult walks the test document and applies the function to each error.

type Recorder

type Recorder interface {
	// ShouldContinue returns whether a test harness should
	// continue to run tests. Typically, this will return false
	// if a fatal test error has been reported.
	ShouldContinue() bool

	// Failed returns true if any errors have been reported.
	Failed() bool

	// NewDocument created a new test document that can be
	// closed by calling the returned Closer.
	NewDocument(desc string) Closer

	// NewDocument created a new test document that can be
	// closed by calling the returned Closer.
	NewStep(desc string) Closer

	Update(...result.Result)
}

Recorder is an object that records structured test information.

var DefaultRecorder Recorder = &defaultRecorder{}

DefaultRecorder ...

func StackRecorders

func StackRecorders(top Recorder, next Recorder) Recorder

StackRecorders returns a new Recorder that stacks top and next. For each method in the Recorder interface, methods from top will be called first, followed by the ones from next.

type RunOpt

type RunOpt func(*testContext)

RunOpt sets options for the test run.

func CheckTimeoutOpt

func CheckTimeoutOpt(timeout time.Duration) RunOpt

CheckTimeoutOpt sets the check timeout.

func DryRunOpt

func DryRunOpt() RunOpt

DryRunOpt enables Kuberentes dry-run mode (TODO).

func KubeClientOpt

func KubeClientOpt(kube *driver.KubeClient) RunOpt

KubeClientOpt sets the Kubernetes client.

func PreserveObjectsOpt

func PreserveObjectsOpt() RunOpt

PreserveObjectsOpt disables automatic object deletion.

func RecorderOpt

func RecorderOpt(r Recorder) RunOpt

RecorderOpt sets the test recorder.

func RegoModuleOpt

func RegoModuleOpt(m *ast.Module) RunOpt

RegoModuleOpt makes the given module available to the Rego evaluation.

func RegoParamOpt

func RegoParamOpt(key string, val string) RunOpt

RegoParamOpt writes a parameter into the Rego store, rooted at the path `/test/params`. If the parameter name contains interior dots (e.g. "foo.bar.baz"), those are converted into path separators.

func TraceRegoOpt

func TraceRegoOpt() RunOpt

TraceRegoOpt enables Rego tracing.

func WatchResourceOpt

func WatchResourceOpt(gvr schema.GroupVersionResource) RunOpt

WatchResourceOpt disables automatic object deletion.

type Step

type Step struct {
	Description string
	Start       time.Time
	End         time.Time
	Results     []result.Result
	Diagnostics map[string]interface{}
}

Step describes a stage in a test document that can generate onr or more related errors.

type SummaryWriter

type SummaryWriter struct {
	// contains filtered or unexported fields
}

SummaryWriter collects a summary of the final test results.

func (*SummaryWriter) Failed

func (s *SummaryWriter) Failed() bool

Failed ...

func (*SummaryWriter) NewDocument

func (s *SummaryWriter) NewDocument(desc string) Closer

NewDocument ...

func (*SummaryWriter) NewStep

func (s *SummaryWriter) NewStep(desc string) Closer

NewStep ...

func (*SummaryWriter) ShouldContinue

func (s *SummaryWriter) ShouldContinue() bool

ShouldContinue ...

func (*SummaryWriter) Summarize

func (s *SummaryWriter) Summarize(out io.Writer)

Summarize write a summary of the test results to out.

func (*SummaryWriter) Update

func (s *SummaryWriter) Update(results ...result.Result)

Update ...

type TapWriter

type TapWriter struct {
	// contains filtered or unexported fields
}

TapWriter writes test records in TAP format. See https://testanything.org/tap-version-13-specification.html

func (*TapWriter) Failed

func (t *TapWriter) Failed() bool

Failed ...

func (*TapWriter) NewDocument

func (t *TapWriter) NewDocument(desc string) Closer

NewDocument ...

func (*TapWriter) NewStep

func (t *TapWriter) NewStep(desc string) Closer

NewStep ...

func (*TapWriter) ShouldContinue

func (t *TapWriter) ShouldContinue() bool

ShouldContinue ...

func (*TapWriter) Update

func (t *TapWriter) Update(results ...result.Result)

Update ...

type TreeWriter

type TreeWriter struct {
	// contains filtered or unexported fields
}

TreeWriter is a Recorder that write test results to a standard output in a tree notation.

func (*TreeWriter) Failed

func (t *TreeWriter) Failed() bool

Failed ...

func (*TreeWriter) NewDocument

func (t *TreeWriter) NewDocument(desc string) Closer

NewDocument ...

func (*TreeWriter) NewStep

func (t *TreeWriter) NewStep(desc string) Closer

NewStep ...

func (*TreeWriter) ShouldContinue

func (t *TreeWriter) ShouldContinue() bool

ShouldContinue ...

func (*TreeWriter) Update

func (t *TreeWriter) Update(results ...result.Result)

Update ...

Jump to

Keyboard shortcuts

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