Documentation ¶
Index ¶
- Constants
- Variables
- func DuplicateAccountErrorResponse() *data.ErrorResponse
- func NewAccountDataFromFile(filename string) *data.Data
- func NewAccountsFromFile(filename string) *data.AccountsData
- func NewErrorMessageFromFile(filename string, statusCode int) *data.ErrorResponse
- func NewRequestMock(response *internalhttp.Response, err error) internalhttp.IRequest
- func NewTestClient(request http.IRequest) *accountsClient.Client
- func ReadJSON(path string) []byte
- func ServerErrorResponse() *data.ErrorResponse
- type RequestMock
Constants ¶
const ErrCouldNotHydrateTestData = "could not hydrate test data"
Variables ¶
var ( //ErrBrokenHTTPClient represents error message from test issues with Request ErrBrokenHTTPClient = fmt.Errorf("broken http connection") )
Functions ¶
func DuplicateAccountErrorResponse ¶
func DuplicateAccountErrorResponse() *data.ErrorResponse
DuplicateAccountErrorResponse returns valid static ErrorResponse for existing Account error.
func NewAccountDataFromFile ¶
NewAccountDataFromFile reads relative file path and returns Data (Account).
func NewAccountsFromFile ¶
func NewAccountsFromFile(filename string) *data.AccountsData
NewAccountsFromFile reads relative file path and returns AccountsData ([]Account).
func NewErrorMessageFromFile ¶
func NewErrorMessageFromFile(filename string, statusCode int) *data.ErrorResponse
NewErrorMessageFromFile reads relative file path and http.StatusCode and returns ErrorResponse.
func NewRequestMock ¶
func NewRequestMock(response *internalhttp.Response, err error) internalhttp.IRequest
NewRequestMock returns Request based on a given test Response. could improve by getting correct urls instead of any.
func NewTestClient ¶
func NewTestClient(request http.IRequest) *accountsClient.Client
NewTestClient is used to inject a mocked Request during tests.
func ServerErrorResponse ¶
func ServerErrorResponse() *data.ErrorResponse
ServerErrorResponse returns valid static ErrorResponse for generic 500 Server Error.
Types ¶
type RequestMock ¶
type RequestMock struct { mock.Mock internalhttp.IRequest }
RequestMock to be able to mock net/http looked into using Pact but with only an external Provider it would be too much to force it to use e2e tests looked into using Sling but had to keep all third party libraries out of the client.
func (*RequestMock) Do ¶
func (r *RequestMock) Do(req *http.Request) (*internalhttp.Response, error)
Do should be mocked to wrap http.Client, and returns http.Response byte array already read in Response.