exec

package
v0.0.0-...-bb701e2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(spec Exec, contextList chan Context) chan *Execution

Run does the same as RunParallel, but in one goroutine.

func RunParallel

func RunParallel(workerCount int, spec Exec, contextList chan Context) chan *Execution

RunParallel executes the supplied exec with each context from the channel. Each execution result ist returned over the result channel, which will be closed after the last execution.

Types

type Context

type Context interface {
	// TestNumber is the number of the actual test.
	TestNumber() int

	// Test returns the configuration data
	// for a single test integration.
	Test() map[string]string

	// Env returns the environment configuration which is common for all
	// test groups.
	Env() map[string]string

	// ExpandVars executes the supplied go template with the context as data context
	ExpandVars(template string) (string, error)

	// ExpandVarsNoError Same as expand vars, but returning template it self in case of an error
	ExpandVarsNoError(template string) string

	// Derive creates a copy of the context, where the test data is
	// field wise overwritten by the supplied test data and the
	// test number is incremented.
	Derive(overrideValues map[string]string) Context

	// Populate can be used to create test data for the number of ExecutionCount tests.
	// It calls the supplied closure for each test and derives a new Context using the test data returned by the supplied function.
	// The creation is done in a go routine and supplied over returned channel.
	// The channel will be closed after sending the last entry.
	Populate(n int, createTestDataClosure func(testNumber int) map[string]string) chan Context

	// CorrelationId is the id which should be transferred in the service chain
	CorrelationId() string
}

type ContextImpl

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

func NewContext

func NewContext(env map[string]string) *ContextImpl

NewContext creates a new context - env base data, which ma be nil

func NewDefaultContext

func NewDefaultContext() *ContextImpl

NewDefaultContext creates a new context without data

func (*ContextImpl) CorrelationId

func (cntx *ContextImpl) CorrelationId() string

func (*ContextImpl) Derive

func (cntx *ContextImpl) Derive(overrideValues map[string]string) Context

func (*ContextImpl) Env

func (cntx *ContextImpl) Env() map[string]string

func (*ContextImpl) ExpandVars

func (cntx *ContextImpl) ExpandVars(tpl string) (string, error)

func (*ContextImpl) ExpandVarsNoError

func (cntx *ContextImpl) ExpandVarsNoError(tpl string) string

func (*ContextImpl) Populate

func (cntx *ContextImpl) Populate(n int, createTestDataClosure func(testNumber int) map[string]string) chan Context

func (*ContextImpl) Test

func (cntx *ContextImpl) Test() map[string]string

func (*ContextImpl) TestNumber

func (cntx *ContextImpl) TestNumber() int

type Exec

type Exec interface {
	// Exec executes the step
	// - cntx the data and reporting context
	Exec(cntx Context) error

	// String returns the description for the step
	String(cntx Context) string
}

Exec is the central interface for executable processing steps

type Execution

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

func StartExecution

func StartExecution(jobTitle string, context *Context) *Execution

func (*Execution) Duration

func (execution *Execution) Duration() time.Duration

func (*Execution) End

func (execution *Execution) End(err error)

func (*Execution) Error

func (execution *Execution) Error() error

func (*Execution) String

func (execution *Execution) String() string

type FuncExec

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

func F

func F(name string, f func() error) *FuncExec

func (*FuncExec) Exec

func (s *FuncExec) Exec(cntx Context) error

func (*FuncExec) String

func (s *FuncExec) String(cntx Context) string

type HttpExec

type HttpExec struct {
	Method string
	Url    string
	Header http.Header
	Body   []byte
	// contains filtered or unexported fields
}

func Get

func Get(url string) *HttpExec
Example
err := Get("https://www.golang.org").
	HasContentType("text/html").
	SelectorContains("div.rootHeading", "Try Java").
	Exec(NewDefaultContext())

fmt.Println(err.Error())
Output:
selection does not contain "Try Java", but was: "Try Go"

func Post

func Post(url string, contentType string, body string) *HttpExec

func (*HttpExec) Contains

func (httpExec *HttpExec) Contains(substring string) *HttpExec

func (*HttpExec) Exec

func (httpExec *HttpExec) Exec(cntx Context) error

func (*HttpExec) Expect

func (httpExec *HttpExec) Expect(e HttpExpectation)

func (*HttpExec) HasCode

func (httpExec *HttpExec) HasCode(code int) *HttpExec

func (*HttpExec) HasCodeRange

func (httpExec *HttpExec) HasCodeRange(min, max int) *HttpExec

func (*HttpExec) HasContentType

func (httpExec *HttpExec) HasContentType(contentType string) *HttpExec

func (*HttpExec) HasNonErrorCode

func (httpExec *HttpExec) HasNonErrorCode() *HttpExec

func (*HttpExec) SelectorContains

func (httpExec *HttpExec) SelectorContains(selector, substring string) *HttpExec

func (*HttpExec) String

func (httpExec *HttpExec) String(cntx Context) string

func (*HttpExec) WithAuthorization

func (httpExec *HttpExec) WithAuthorization(authorizationHeader string) *HttpExec

func (*HttpExec) WithBasicAuth

func (httpExec *HttpExec) WithBasicAuth(username, password string) *HttpExec

type HttpExpectation

type HttpExpectation func(response *http.Response, body string) error

type Repository

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

A repository is a set of test groups with tests.

func NewRepository

func NewRepository() *Repository

func (*Repository) Add

func (repo *Repository) Add(scenario *TestScenario, testGroup string, concurrency int, tags ...string)

func (*Repository) GetErrorExecutions

func (repo *Repository) GetErrorExecutions() []*Execution

func (*Repository) RunTestScenarios

func (repo *Repository) RunTestScenarios(testGroupRegex string, nameRegex string, tagPatterns ...string)

Run all testScenarios, which match the supplied filter criteria.

type SequenceExec

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

func Seq

func Seq(name string, steps ...Exec) *SequenceExec

func (*SequenceExec) Add

func (s *SequenceExec) Add(r Exec) *SequenceExec

Add a Step to the SequenceExec

func (*SequenceExec) AddN

func (s *SequenceExec) AddN(n int, r Exec) *SequenceExec

Add a Step n times to the SequenceExec

func (*SequenceExec) Exec

func (s *SequenceExec) Exec(cntx Context) error

func (*SequenceExec) String

func (s *SequenceExec) String() string

type TestFactory

type TestFactory func(Context) (Exec, chan Context)

TestFactory is a factory method which returns a test with its data.

type TestScenario

type TestScenario struct {
	Name                  string
	Exec                  Exec
	ContextChannelFactory func() chan Context
}

func NewTestScenario

func NewTestScenario(name string, exec Exec, contextChannelFactory func() chan Context) *TestScenario

Jump to

Keyboard shortcuts

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