Documentation ¶
Index ¶
- Variables
- func AssertAdapt(t *testing.T, rawConfig string, adapterName string, expectedResponse string)
- func AssertLoadError(t *testing.T, rawConfig string, configType string, expectedError string)
- func CompareAdapt(t *testing.T, filename, rawConfig string, adapterName string, ...) bool
- func CreateTestingTransport() *http.Transport
- type Defaults
- type Tester
- func (tc *Tester) AssertDeleteResponse(requestURI string, expectedStatusCode int, expectedBody string) (*http.Response, string)
- func (tc *Tester) AssertGetResponse(requestURI string, expectedStatusCode int, expectedBody string) (*http.Response, string)
- func (tc *Tester) AssertPatchResponseBody(requestURI string, requestHeaders []string, requestBody *bytes.Buffer, ...) (*http.Response, string)
- func (tc *Tester) AssertPostResponseBody(requestURI string, requestHeaders []string, requestBody *bytes.Buffer, ...) (*http.Response, string)
- func (tc *Tester) AssertPutResponseBody(requestURI string, requestHeaders []string, requestBody *bytes.Buffer, ...) (*http.Response, string)
- func (tc *Tester) AssertRedirect(requestURI string, expectedToLocation string, expectedStatusCode int) *http.Response
- func (tc *Tester) AssertResponse(req *http.Request, expectedStatusCode int, expectedBody string) (*http.Response, string)
- func (tc *Tester) AssertResponseCode(req *http.Request, expectedStatusCode int) *http.Response
- func (tc *Tester) InitServer(rawConfig string, configType string)
Constants ¶
This section is empty.
Variables ¶
var Default = Defaults{ AdminPort: 2019, Certifcates: []string{"/caddy.localhost.crt", "/caddy.localhost.key"}, TestRequestTimeout: 5 * time.Second, LoadRequestTimeout: 5 * time.Second, }
Default testing values
Functions ¶
func AssertAdapt ¶
AssertAdapt adapts a config and then tests it against an expected result
func AssertLoadError ¶
AssertLoadError will load a config and expect an error
func CompareAdapt ¶
func CompareAdapt(t *testing.T, filename, rawConfig string, adapterName string, expectedResponse string) bool
CompareAdapt adapts a config and then compares it against an expected result
func CreateTestingTransport ¶
CreateTestingTransport creates a testing transport that forces call dialing connections to happen locally
Types ¶
type Defaults ¶
type Defaults struct { // Port we expect caddy to listening on AdminPort int // Certificates we expect to be loaded before attempting to run the tests Certifcates []string // TestRequestTimeout is the time to wait for a http request to TestRequestTimeout time.Duration // LoadRequestTimeout is the time to wait for the config to be loaded against the caddy server LoadRequestTimeout time.Duration }
Defaults store any configuration required to make the tests run
type Tester ¶
Tester represents an instance of a test client.
func (*Tester) AssertDeleteResponse ¶
func (tc *Tester) AssertDeleteResponse(requestURI string, expectedStatusCode int, expectedBody string) (*http.Response, string)
AssertDeleteResponse request a URI and expect a statusCode and body text
func (*Tester) AssertGetResponse ¶
func (tc *Tester) AssertGetResponse(requestURI string, expectedStatusCode int, expectedBody string) (*http.Response, string)
AssertGetResponse GET a URI and expect a statusCode and body text
func (*Tester) AssertPatchResponseBody ¶
func (tc *Tester) AssertPatchResponseBody(requestURI string, requestHeaders []string, requestBody *bytes.Buffer, expectedStatusCode int, expectedBody string) (*http.Response, string)
AssertPatchResponseBody PATCH to a URI and assert the response code and body
func (*Tester) AssertPostResponseBody ¶
func (tc *Tester) AssertPostResponseBody(requestURI string, requestHeaders []string, requestBody *bytes.Buffer, expectedStatusCode int, expectedBody string) (*http.Response, string)
AssertPostResponseBody POST to a URI and assert the response code and body
func (*Tester) AssertPutResponseBody ¶
func (tc *Tester) AssertPutResponseBody(requestURI string, requestHeaders []string, requestBody *bytes.Buffer, expectedStatusCode int, expectedBody string) (*http.Response, string)
AssertPutResponseBody PUT to a URI and assert the response code and body
func (*Tester) AssertRedirect ¶
func (tc *Tester) AssertRedirect(requestURI string, expectedToLocation string, expectedStatusCode int) *http.Response
AssertRedirect makes a request and asserts the redirection happens
func (*Tester) AssertResponse ¶
func (tc *Tester) AssertResponse(req *http.Request, expectedStatusCode int, expectedBody string) (*http.Response, string)
AssertResponse request a URI and assert the status code and the body contains a string
func (*Tester) AssertResponseCode ¶
AssertResponseCode will execute the request and verify the status code, returns a response for additional assertions
func (*Tester) InitServer ¶
InitServer this will configure the server with a configurion of a specific type. The configType must be either "json" or the adapter type.