tester

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2018 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contract

type Contract struct {
	Name    string            `json:"name" yaml:"name"`
	Path    string            `json:"path" yaml:"path"`
	Method  string            `json:"method" yaml:"method"`
	Body    string            `json:"body" yaml:"body"`
	Headers map[string]string `json:"headers" yaml:"headers"`

	Locals map[string]string `json:"locals" yaml:"locals"`

	Outputs map[string]string `json:"outputs" yaml:"outputs"`

	ExpectedHTTPCode     int    `json:"http_code_is" yaml:"http_code_is"`
	ExpectedResponseBody string `json:"response_body_contains" yaml:"response_body_contains"`
}

Contract represents the data for a single test case: the definition of the HTTP call and the expected result

type Option

type Option func(*Runner)

Option is a function which can change some properties of the Runner

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient returns an Option which overrides the default http client

func WithVerboseModeOn

func WithVerboseModeOn(verboseMode bool) Option

WithVerboseModeOn returns an Option which sets the verbosity of the runner. Default is false.

type Runner

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

Runner is the primary struct of this package and is responsible for running the test suite

func NewRunner

func NewRunner(url string, test Test, opts ...Option) *Runner

NewRunner returns a *Runner for a given url and Test.

func (*Runner) Run

func (runner *Runner) Run() bool

Run is the method which runs the Test associated with this Runner. Returns a bool representing the result of the test.

type Test

type Test struct {
	Globals map[string]string `json:"globals" yaml:"globals"`

	Contracts []Contract `json:"contracts" yaml:"contracts"`
}

Test represents the data for a full test suite

Jump to

Keyboard shortcuts

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