Documentation ¶
Index ¶
- func LoadFixture(name string) ([]byte, error)
- func MakeMockClient(mockOptions SimpleMockOptions) *misskey.Client
- func Must(content []byte, err error) []byte
- func NewMockResponse(code int, content []byte, err error) (*http.Response, error)
- func ValidateRequests(t *testing.T, invalidRequests []core.BaseRequest, ...)
- type BadReadCloser
- type FixtureFileNotFound
- type MockBody
- type MockHTTPClient
- type MockRequestHandler
- type MockType
- type SimpleMockOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadFixture ¶
LoadFixture loads the content of a fixture file.
func MakeMockClient ¶
func MakeMockClient(mockOptions SimpleMockOptions) *misskey.Client
MakeMockClient creates a new Client with SimpleMockOptions.
func NewMockResponse ¶
NewMockResponse creates a new mock response.
func ValidateRequests ¶
func ValidateRequests(t *testing.T, invalidRequests []core.BaseRequest, validRequests []core.BaseRequest)
ValidateRequests validates requests with their Validate function and check if error occurred or not.
Types ¶
type BadReadCloser ¶
type BadReadCloser struct{}
BadReadCloser is a basic ReadCloser with error. The only purpose is to test what is the connection dropped or something.
type FixtureFileNotFound ¶
FixtureFileNotFound occurs when the requested fixture file does not exist.
func (FixtureFileNotFound) Error ¶
func (e FixtureFileNotFound) Error() string
type MockHTTPClient ¶
type MockHTTPClient struct {
// contains filtered or unexported fields
}
MockHTTPClient is a very basic mock implementation of the HTTPClient.
func NewMockHTTPClient ¶
func NewMockHTTPClient() *MockHTTPClient
NewMockHTTPClient boostraps a new MockHTTPClient.
func SimpleMockEndpoint ¶
func SimpleMockEndpoint(options *SimpleMockOptions) *MockHTTPClient
SimpleMockEndpoint creates a simple MockHTTPClient that returns with an error if it was not able to pasre the request or returns with the content of the provided fixture file.
func (*MockHTTPClient) MockRequest ¶
func (c *MockHTTPClient) MockRequest(path string, handler MockRequestHandler)
MockRequest registers a new endpoint.
type MockRequestHandler ¶
MockRequestHandler is just an alias for the function signature used to hanle mock requests.