Documentation ¶
Overview ¶
Package test provides utility methods to test APIs based on the common API.
Index ¶
- Variables
- func BothEndpoints(t *testing.T, test Func)
- func CheckHeaders(t *testing.T, expected map[string][]string, url string, headers http.Header)
- func HTTPClient(t *testing.T, h host.Host, isHTTPS bool) *http.Client
- func HTTPSEndPoint(t *testing.T, test Func)
- func HTTPURL(a API) string
- func IsHTTPS(url string) bool
- func MakeDelete(t *testing.T, api API, url string, resp interface{})
- func MakeGet(t *testing.T, api API, url string, resp interface{})
- func MakeHost(t *testing.T, api API) host.Host
- func MakeOptions(t *testing.T, api API, url string, reqHeaders http.Header) http.Header
- func MakePost(t *testing.T, api API, url string, body []byte, resp interface{})
- func MakePostWithContentType(t *testing.T, api API, url string, body []byte, contentType string, ...)
- func MakeStreamingGet(t *testing.T, api API, url string, resp interface{}, trailerError bool)
- func MakeStreamingPost(t *testing.T, api API, url string, body io.Reader, contentType string, ...)
- func P2pURL(a API) string
- func ProcessResp(t *testing.T, httpResp *http.Response, err error, resp interface{})
- func ProcessStreamingResp(t *testing.T, httpResp *http.Response, err error, resp interface{}, ...)
- type API
- type Func
- type URLFunc
Constants ¶
This section is empty.
Variables ¶
var ( // SSLCertFile is the location of the certificate file. // Used in HTTPClient to set the right certificate when // creating an HTTPs client. Might need adjusting depending // on where the tests are running. SSLCertFile = "test/server.crt" // ClientOrigin sets the Origin header for requests to this. ClientOrigin = "myorigin" )
Functions ¶
func BothEndpoints ¶
BothEndpoints runs a test.Func against the http and p2p endpoints.
func CheckHeaders ¶
CheckHeaders checks that all the headers are set to what is expected.
func HTTPClient ¶
HTTPClient returns a client that supporst both http/https and libp2p-tunneled-http.
func HTTPSEndPoint ¶
HTTPSEndPoint runs the given test.Func against an HTTPs endpoint.
func MakeDelete ¶
MakeDelete performs a DELETE request against the given API.
func MakeOptions ¶
MakeOptions performs an OPTIONS request against the given api.
func MakePostWithContentType ¶
func MakePostWithContentType(t *testing.T, api API, url string, body []byte, contentType string, resp interface{})
MakePostWithContentType performs a POST with the given body and content-type.
func MakeStreamingGet ¶
MakeStreamingGet performs a GET request and uses ProcessStreamingResp
func MakeStreamingPost ¶
func MakeStreamingPost(t *testing.T, api API, url string, body io.Reader, contentType string, resp interface{})
MakeStreamingPost performs a POST request and uses ProcessStreamingResp
func ProcessResp ¶
ProcessResp puts a response into a given type or fails the test.
Types ¶
type API ¶
type API interface { HTTPAddresses() ([]string, error) Host() host.Host Headers() map[string][]string }
API represents what an API is to us.