Documentation ¶
Overview ¶
Package tests implements utility functions to help with API Gateway testing.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultBackendBuilder mockBackendBuilder
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 ComposableBackendBuilder ¶ added in v2.3.3
type ComposableBackendBuilder interface {
NewGenericServer(*Config) GenericServer
}
ComposableBackendBuilder allows us to return a more generic interface for any kind of server.
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 GenericServer ¶ added in v2.3.3
GenericServer defines an interface to launch a server that could be an http.Server, a different type, or a wrapper around multiple servers.
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"` Schema map[string]interface{} `json:"schema"` }
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