Documentation ¶
Overview ¶
Description: This package contains helper functions to be used in tests.
Index ¶
- func AssertResponse(expectedStatusCode int, resp *http.Response, responseBody []byte) error
- func CheckErrorAndFail(t *testing.T, err error)
- func CheckErrorAndFailWithMessage(t *testing.T, err error, debugMessage string)
- func NewMockPubSubPayload(message *pubsub.Message, subscriptionMockValue string) (*bytes.Buffer, error)
- type PubSubMessage
- type PubSubPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertResponse ¶
AssertResponse is a function that checks if the status code of an HTTP response matches the expected status code.
It takes an expected status code, an HTTP response, and a response body as parameters.
If the status code of the response does not match the expected status code, it returns an error with a message indicating the expected and actual status codes and the response body.
If the status code of the response matches the expected status code, it returns nil.
func CheckErrorAndFail ¶
CheckErrorAndFail is a function that checks if an error is not nil and fails the test if it is.
It takes a testing.T and an error as parameters.
If the error is not nil, it calls t.Fatalf with the error message, causing the test to fail.
This function is intended to be used with a test level (global) error field.
func CheckErrorAndFailWithMessage ¶
CheckErrorAndFail is a function that checks if an error is not nil and fails the test if it is.
It takes a testing.T and an error as parameters.
If the error is not nil, it calls t.Fatalf with the error message, causing the test to fail.
This function is intended to be used with a test level (global) error field.
Types ¶
type PubSubMessage ¶
type PubSubMessage struct { Data []byte `json:"data,omitempty"` Attributes map[string]string `json:"attributes,omitempty"` MessageID string `json:"messageId,omitempty"` PublishTime time.Time `json:"publishTime,omitempty"` }
PubSubMessage is the model for a Google Pub/Sub message.
type PubSubPayload ¶
type PubSubPayload struct { Message PubSubMessage `json:"message,omitempty"` Subscription string `json:"subscription,omitempty"` }
PubSubPayload is the model for a Google Pub/Sub payload.