httpcheck

package
v0.0.0-...-df19b13 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2016 License: BSD-2-Clause Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RequestTimeout uint = 5 // Timeout for each HTTP request (seconds)
View Source
var ServerTimeout uint = 120 // Timeout for a server's tests (seconds)
View Source
var Verbose = false // If true, every request is printed to standard output

Functions

This section is empty.

Types

type Manifest

type Manifest []Server

Manifest contains one or more Servers, each having some Scenarios.

func FromYAML

func FromYAML(y []byte) (Manifest, error)

FromYAML parses YAML input and returns a manifest.

func (*Manifest) SetBaseURL

func (m *Manifest) SetBaseURL(baseurl string)

SetBaseURL walks through all tests and prefixes any relative URLs (e.g. '/') with a base URL.

func (Manifest) Test

func (m Manifest) Test() error

Test runs tests on all servers in the manifest. It returns an error if one or more server has errors, or nil otherwise. In case there are multiple errors, the error contains the concatenated messages.

type Method

type Method int

type Scenario

type Scenario struct {
	Name  string
	Tests Tests "test,flow"
}

A Scenario describes multiple tests executed in-order. Cookies are preserved within a scenario, so tests can depend on earlier tests.

func (Scenario) String

func (s Scenario) String() string

func (Scenario) Test

func (s Scenario) Test() error

Test runs the tests in this scenario in order, stopping at the first error. It returns an error if one of the tests in the scenario has errors, or nil otherwise.

type Server

type Server struct {
	Name      string "server"
	Scenarios []Scenario
}

A Server has a number of Scenarios to test.

func (Server) Test

func (server Server) Test() error

Test runs tests on the scenarios and tests for this server. It returns an error if one or more scenarios/tests has errors, or nil otherwise. In case there are multiple errors, the error contains the concatenated messages.

type Test

type Test struct {
	Url     string            // A fully specified URL including the protocol
	Content string            ",omitempty" // Expected content as a regexp, e.g. "Hello World"
	Code    int               ",omitempty" // Expected HTTP response code
	Method  string            ",omitempty" // HTTP method, i.e. "GET" (default) or "POST"
	Type    string            ",omitempty" // Optional value for Content-Type header
	Data    string            ",omitempty" // Optional post data
	Headers map[string]string ",omitempty" // Optional headers to add to the request
}

A single HTTP action, with the expected results.

func (Test) CheckCode

func (t Test) CheckCode(code int) error

CheckCode inspects the received HTTP response code

func (Test) CheckContent

func (t Test) CheckContent(body string) error

CheckContent inspects the returned HTTP response body

func (Test) ContentType

func (t Test) ContentType() string

func (Test) DoRequest

func (t Test) DoRequest() (code int, body string, err error)

DoRequest uses the global http object to send a HTTP request

func (Test) MethodName

func (t Test) MethodName() string

func (Test) NewError

func (t Test) NewError(message string) error

func (Test) String

func (t Test) String() string

func (Test) Test

func (t Test) Test() (err error)

Test makes a HTTP call and checks the response

func (Test) Validate

func (t Test) Validate() error

type Tester

type Tester interface {
	Test() error
}

type Tests

type Tests []Test

Jump to

Keyboard shortcuts

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