# Functions
AssertAPIRequest sends sends api request and checks api response (see docs for APIRequest and APIResponse) to the provided testServer using the provided APIPrefix.
AssertReportResponsesEqual checks if reports in answer are the same.
AssertReportResponsesEqualCustomElementsChecker checks if reports in answer are the same using custom checker for elements.
AssertRuleResponsesEqual checks if rules in answer are the same.
AssertStringsAreEqualJSON checks whether strings represent the same JSON (whitespaces and order of elements doesn't matter) and asserts error otherwise.
CatchingOutputs execute a function capturing and returning Stdout and Stderr for later checks.
CheckResponseBodyJSON checks if body is the same json as in expected (ignores whitespaces, newlines, etc) also validates both expected and body to be a valid json.
CleanAfterGock cleans after gock library and prints all unmatched requests.
CompareReportResponses compares two RuleOnReport struct field by field, except for the CreatedAt field that is compared with createdAt timestamp.
ExecuteRequest executes http request on a testServer.
FailOnError logs error and stops next test's execution if non nil value is passed to err optionally, you can add a message.
FrisbyExpectItemInArray returns checker function for frisby to check if item is in the array Example:
frisby.Create("test creating organization").
GockExpectAPIRequest makes gock expect the request with the baseURL and sends back the response.
IsStringJSON check if the string is a JSON.
JSONUnmarshalStrict unmarshales json and returns error if some field exist in data, but not in outObj.
MakeXRHTokenString converts types.Token to a token string(base64 encoded).
MustGobSerialize serializes an object using gob or panics.
NewGockAPIEndpointMatcher returns new matcher for github.com/h2non/gock to match endpoint with any args.
NewGockRequestMatcher returns a new matcher for github.com/h2non/gock to match requests with provided method, url and body(the same types as body in APIRequest(see the docs)).
NewMicroHTTPServer creates a MicroHTTPServer for the given address and prefix.
NewMockT constructs a new instance of MockT.
RunTestWithTimeout runs test with timeToRun timeout and fails if it wasn't in time.
SortReports sorts a list of RuleOnReport by ErrorKey field.
ToJSONPrettyString converts anything to indented JSON or panics if it's not possible.
ToJSONString converts anything to JSON or panics if it's not possible.
# Structs
APIRequest is a request to api to use in AssertAPIRequest
(required) Method is an http method (required) Endpoint is an endpoint without api prefix EndpointArgs are the arguments to pass to endpoint template (leave empty if endpoint is not a template) Body is a request body which can be a string or []byte (leave empty to not send) UserID is a user id for methods requiring user id (leave empty to not use it) OrgID is an org id for methods requiring it to be in token (leave empty to not use it) XRHIdentity is an authentication token (leave empty to not use it) AuthorizationToken is an authentication token (leave empty to not use it).
APIResponse is an expected api response to use in AssertAPIRequest
StatusCode is an expected http status code (leave empty to not check for status code) Body is an expected body which can be a string or []byte(leave empty to not check for body) BodyChecker is a custom body checker function (leave empty to use default one - CheckResponseBodyJSON).
MicroHTTPServer in an implementation of ServerInitializer interface This small implementation could help implementing tests without using a real HTTP server implementation.
MockT wraps testing.T to be able to test functions accepting testing.TB.
# Interfaces
ServerInitializer is interface which is implemented for any server having Initialize method.
# Type aliases
BodyChecker represents body checker type for api response.
TestFunctionPtr pointer to test function.