Help us shape the future of Go! Take the 2026 Go Developer Survey

testsuites

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateAssertions

func ValidateAssertions(res *Result, assertions []string, runres *RunResult) error

ValidateAssertions runs the assertions of a test spec against a run result and sets the result appropriately

Types

type ErrResult

type ErrResult struct {
	Message string `yaml:"message" xml:"message,attr"`
	Type    string `yaml:"type" xml:"type,attr"`
}

ErrResult indicates failure

type Executor

type Executor interface {
	Run(ctx context.Context, spec *Spec) (*RunResult, error)
}

Executor can run test commands in some environment

type LocalExecutor

type LocalExecutor struct{}

LocalExecutor executes tests against the current, local environment

func (LocalExecutor) Run

func (LocalExecutor) Run(ctx context.Context, s *Spec) (res *RunResult, err error)

Run executes the test

type Result

type Result struct {
	XMLName xml.Name `xml:"testsuite"`

	Desc string `yaml:"desc" xml:"name,attr"`

	Skipped bool       `yaml:"skipped,omitempty" xml:"skippped"`
	Error   *ErrResult `yaml:"error,omitempty" xml:"error"`
	Failure *ErrResult `yaml:"failure,omitempty" xml:"failure"`

	*RunResult
}

Result is the result of a test

type Results

type Results struct {
	XMLName xml.Name `xml:"testsuites"`

	Result []*Result `yaml:"results" xml:"testsuite"`
}

Results is a collection of test results

func RunTests

func RunTests(ctx context.Context, executor Executor, tests []*Spec) (res Results, success bool)

RunTests executes a series of tests

type RunResult

type RunResult struct {
	Stdout     []byte `yaml:"stdout,omitempty" xml:"system-out,omitempty"`
	Stderr     []byte `yaml:"stderr,omitempty" xml:"system-err,omitempty"`
	StatusCode int64  `yaml:"statusCode" xml:"-"`
}

RunResult is the direct output produced by a test container

type Spec

type Spec struct {
	Desc string `yaml:"desc"`

	Skip       bool     `yaml:"skip,omitempty"`
	User       string   `yaml:"user,omitempty"`
	Command    []string `yaml:"command,flow"`
	Entrypoint []string `yaml:"entrypoint,omitempty,flow"`
	Env        []string `yaml:"env,omitempty"`

	Assertions []string `yaml:"assert"`
}

Spec specifies a command execution test against a Docker image

func (*Spec) Run

func (s *Spec) Run(ctx context.Context, executor Executor) (res *Result)

Run executes the test

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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