Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMockHTTPClient ¶
func GetMockHTTPClient(rt RoundTripper) *http.Client
Types ¶
type RoundTripper ¶
type RoundTripper struct { // Response mock GetResponse func(req *http.Request) (*http.Response, error) HARFileName string // filename (relative path of where it is being called) GetFileName func(req *http.Request) string FileName string // filename (relative path of where it is being called) GetBody func(req *http.Request) string Body string // Response status and headers StatusCode int Status string ResponseHeaders map[string]string // Authentication BasicAuthEnabled bool BasicAuthUser string BasicAuthPassword string }
func (*RoundTripper) RoundTrip ¶
RoundTrip provides a http transport method for simulating http response If GetResponse present and return non-nil values, they will be returned. This will be useful to mock authentication errors bases on request headers Else If HARFileName present, it will take priority Else if GetFileName present and return valid file name, it will respond with corresponding file content Else if FileName present, it will read the response from the filename Else if GetBody present and return valid string, it will respond with corresponding string Else if Body present, it will echo the body Else default response {} will be sent
Click to show internal directories.
Click to hide internal directories.