Documentation ¶
Overview ¶
Package tests implements utility functions to help with API Gateway testing.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewIntegration ¶
func NewIntegration(cfg *Config, cb CmdBuilder, bb BackendBuilder) (*Runner, []TestCase, error)
NewIntegration sets up a runner for the integration test and returns it with the parsed specs from the specs folder and an error signaling if something went wrong. It uses the default values for any nil argument
Example ¶
runner, tcs, err := NewIntegration(nil, nil, nil) if err != nil { fmt.Println(err) return } defer runner.Close() for _, tc := range tcs { if err := runner.Check(tc); err != nil { fmt.Printf("%s: %s", tc.Name, err.Error()) return } }
Output: signal: killed
Types ¶
type BackendBuilder ¶
BackendBuilder defines an interface for building a server as a backend for the tests
type CmdBuilder ¶
CmdBuilder defines an interface for building the cmd to be managed by the Runner
type Config ¶
type Config struct { BinPath string CfgPath string SpecsPath string EnvironPatterns string BackendPort int Delay time.Duration HttpClient *http.Client }
Config contains options for running a test.
type Input ¶
type Input struct { URL string `json:"url"` Method string `json:"method"` Header map[string]string `json:"header"` Body interface{} `json:"body"` }
Input is the definition of the request to send in a given TestCase
type Output ¶
type Output struct { StatusCode int `json:"status_code"` Body interface{} `json:"body"` Header map[string][]string `json:"header"` }
Output contains the data required to verify the response received in a given TestCase
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner handles the integration test execution, by dealing with the request generation, response verification and the final shutdown