Documentation ¶
Overview ¶
Package test contains the infrastructure for a proxy tester. Individual tests are found in github.com/seehuhn/jvproxy/tester/lib .
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RandomString ¶
RandomString returns a random string of length `n`, composed of upper- and lower-case letters as well as digits.
Types ¶
type Case ¶
type Case func(Helper, ...interface{})
A Case represents a single unit test for the proxy. The Helper object should be used to generate HTTP requests and responses, and to report the test outcome. Test cases can only be run via Runner.Run(). The optional arguments used in the call to Runner.Run() are passed through to the test case without change.
type Helper ¶
type Helper interface { NewRequest(method string) *http.Request SendRequestToServer(*http.Request) (http.Header, *http.Request) SendResponseToClient(int, *ResponseBodySpec) http.Header Log(format string, a ...interface{}) Fail(format string, a ...interface{}) Pass(format string, a ...interface{}) SetInfo(name, RFC string) }
Helper objects allow test cases to generate HTTP requests and responses, and to report the test outcome. The only way to generate Helper objects is via the Runner.Run() method.
type LogEntry ¶
A LogEntry summarises the results of a single proxy test. The log entry is composed of the proxy test name, a boolean to indicate whether the proxy passed the test, and a list of messages.
type ResponseBodySpec ¶
type ResponseBodySpec struct { // Seed is used to initialise the random number generator for // generating the response. Small positive integers should be to // select which response to generate. Seed int64 // Length specifies the required response body size in bytes. The // length does not include the response header. Length int64 }
ResponseBodySpec describes a (synthetic) server response.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
A Runner provides the infrastructure to run a series of tests on a HTTP proxy.
func NewRunner ¶
NewRunner allocates a new test.Runner for testing the given proxy. Test results will be written to the `LogEntry` channel.