Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIClient ¶
type APIClient interface {
// Delete does a DELETE response to the APIClient
Delete(t *testing.T, path string) APIRequest
// Get does a GET response to the APIClient
Get(t *testing.T, path string) APIRequest
// Post does a POST response to the APIClient
Post(t *testing.T, path string) APIRequest
// Put does a PUT response to the APIClient
Put(t *testing.T, path string) APIRequest
// Request does a response to the APIClient
Request(t *testing.T, method string, path string) APIRequest
// ReverseURL creates a path by given url name and url arguments
ReverseURL(t *testing.T, name string, vars ...string) string
}
APIClient is the interface for testing the rest APIClient
type APIRequest ¶
type APIRequest interface {
// Body sets the body of the request
Body(t *testing.T, body any) APIRequest
// Do perform the request and returns the response
Do(t *testing.T, ctx context.Context) APIResponse
// Header sets the header of the request
Header(t *testing.T, key, value string) APIRequest
// Query sets the query of the request
Query(t *testing.T, key, value string) APIRequest
}
APIRequest is the interface for testing the rest APIClient response
type APIResponse ¶
type APIResponse interface {
// AssertJsonEquals asserts that response body is equal to given json
AssertJsonEquals(t *testing.T, what any) APIResponse
// AssertJsonKeyEquals asserts that response body key is equal to given value
AssertJsonKeyEquals(t *testing.T, key string, what any) APIResponse
// AssertStatus asserts that response status is equal to given status
AssertStatus(t *testing.T, status int) APIResponse
// Unmarshal json unmarshalls whole response body into given value
Unmarshal(t *testing.T, v any) APIResponse
}
APIResponse is the interface for testing the rest APIClient response
Click to show internal directories.
Click to hide internal directories.