Documentation ¶
Overview ¶
Package http_helper contains helpers to interact with deployed resources through HTTP.
Index ¶
- func ContinuouslyCheckUrl(t testing.TestingT, url string, stopChecking <-chan bool, ...) (*sync.WaitGroup, <-chan GetResponse)
- func HTTPDo(t testing.TestingT, method string, url string, body io.Reader, ...) (int, string)
- func HTTPDoE(t testing.TestingT, method string, url string, body io.Reader, ...) (int, string, error)
- func HTTPDoWithCustomValidation(t testing.TestingT, method string, url string, body io.Reader, ...)
- func HTTPDoWithCustomValidationE(t testing.TestingT, method string, url string, body io.Reader, ...) error
- func HTTPDoWithCustomValidationWithOptions(t testing.TestingT, options HttpDoOptions, ...)
- func HTTPDoWithCustomValidationWithOptionsE(t testing.TestingT, options HttpDoOptions, ...) error
- func HTTPDoWithOptions(t testing.TestingT, options HttpDoOptions) (int, string)
- func HTTPDoWithOptionsE(t testing.TestingT, options HttpDoOptions) (int, string, error)
- func HTTPDoWithRetry(t testing.TestingT, method string, url string, body []byte, ...) string
- func HTTPDoWithRetryE(t testing.TestingT, method string, url string, body []byte, ...) (string, error)
- func HTTPDoWithRetryWithOptions(t testing.TestingT, options HttpDoOptions, expectedStatus int, retries int, ...) string
- func HTTPDoWithRetryWithOptionsE(t testing.TestingT, options HttpDoOptions, expectedStatus int, retries int, ...) (string, error)
- func HTTPDoWithValidation(t testing.TestingT, method string, url string, body io.Reader, ...)
- func HTTPDoWithValidationE(t testing.TestingT, method string, url string, body io.Reader, ...) error
- func HTTPDoWithValidationRetry(t testing.TestingT, method string, url string, body []byte, ...)
- func HTTPDoWithValidationRetryE(t testing.TestingT, method string, url string, body []byte, ...) error
- func HTTPDoWithValidationRetryWithOptions(t testing.TestingT, options HttpDoOptions, expectedStatus int, ...)
- func HTTPDoWithValidationRetryWithOptionsE(t testing.TestingT, options HttpDoOptions, expectedStatus int, ...) error
- func HTTPDoWithValidationWithOptions(t testing.TestingT, options HttpDoOptions, expectedStatusCode int, ...)
- func HTTPDoWithValidationWithOptionsE(t testing.TestingT, options HttpDoOptions, expectedStatusCode int, ...) error
- func HttpGet(t testing.TestingT, url string, tlsConfig *tls.Config) (int, string)
- func HttpGetE(t testing.TestingT, url string, tlsConfig *tls.Config) (int, string, error)
- func HttpGetWithCustomValidation(t testing.TestingT, url string, tlsConfig *tls.Config, ...)
- func HttpGetWithCustomValidationE(t testing.TestingT, url string, tlsConfig *tls.Config, ...) error
- func HttpGetWithCustomValidationWithOptions(t testing.TestingT, options HttpGetOptions, ...)
- func HttpGetWithCustomValidationWithOptionsE(t testing.TestingT, options HttpGetOptions, ...) error
- func HttpGetWithOptions(t testing.TestingT, options HttpGetOptions) (int, string)
- func HttpGetWithOptionsE(t testing.TestingT, options HttpGetOptions) (int, string, error)
- func HttpGetWithRetry(t testing.TestingT, url string, tlsConfig *tls.Config, expectedStatus int, ...)
- func HttpGetWithRetryE(t testing.TestingT, url string, tlsConfig *tls.Config, expectedStatus int, ...) error
- func HttpGetWithRetryWithCustomValidation(t testing.TestingT, url string, tlsConfig *tls.Config, retries int, ...)
- func HttpGetWithRetryWithCustomValidationE(t testing.TestingT, url string, tlsConfig *tls.Config, retries int, ...) error
- func HttpGetWithRetryWithCustomValidationWithOptions(t testing.TestingT, options HttpGetOptions, retries int, ...)
- func HttpGetWithRetryWithCustomValidationWithOptionsE(t testing.TestingT, options HttpGetOptions, retries int, ...) error
- func HttpGetWithRetryWithOptions(t testing.TestingT, options HttpGetOptions, expectedStatus int, ...)
- func HttpGetWithRetryWithOptionsE(t testing.TestingT, options HttpGetOptions, expectedStatus int, ...) error
- func HttpGetWithValidation(t testing.TestingT, url string, tlsConfig *tls.Config, expectedStatusCode int, ...)
- func HttpGetWithValidationE(t testing.TestingT, url string, tlsConfig *tls.Config, expectedStatusCode int, ...) error
- func HttpGetWithValidationWithOptions(t testing.TestingT, options HttpGetOptions, expectedStatusCode int, ...)
- func HttpGetWithValidationWithOptionsE(t testing.TestingT, options HttpGetOptions, expectedStatusCode int, ...) error
- func RunDummyServer(t testing.TestingT, text string) (net.Listener, int)
- func RunDummyServerE(t testing.TestingT, text string) (net.Listener, int, error)
- func RunDummyServerWithHandlers(t testing.TestingT, ...) (net.Listener, int)
- func RunDummyServerWithHandlersE(t testing.TestingT, ...) (net.Listener, int, error)
- type GetResponse
- type HttpDoOptions
- type HttpGetOptions
- type ValidationFunctionFailed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContinuouslyCheckUrl ¶ added in v0.13.16
func ContinuouslyCheckUrl( t testing.TestingT, url string, stopChecking <-chan bool, sleepBetweenChecks time.Duration, ) (*sync.WaitGroup, <-chan GetResponse)
Continuously check the given URL every 1 second until the stopChecking channel receives a signal to stop. This function will return a sync.WaitGroup that can be used to wait for the checking to stop, and a read only channel to stream the responses for each check. Note that the channel has a buffer of 1000, after which it will start to drop the send events
func HTTPDo ¶ added in v0.18.5
func HTTPDo( t testing.TestingT, method string, url string, body io.Reader, headers map[string]string, tlsConfig *tls.Config, ) (int, string)
HTTPDo performs the given HTTP method on the given URL and return the HTTP status code and body. If there's any error, fail the test.
func HTTPDoE ¶ added in v0.18.5
func HTTPDoE( t testing.TestingT, method string, url string, body io.Reader, headers map[string]string, tlsConfig *tls.Config, ) (int, string, error)
HTTPDoE performs the given HTTP method on the given URL and return the HTTP status code, body, and any error.
func HTTPDoWithCustomValidation ¶ added in v0.18.5
func HTTPDoWithCustomValidation(t testing.TestingT, method string, url string, body io.Reader, headers map[string]string, validateResponse func(int, string) bool, tlsConfig *tls.Config)
HTTPDoWithCustomValidation performs the given HTTP method on the given URL and validate the returned status code and body using the given function.
func HTTPDoWithCustomValidationE ¶ added in v0.18.5
func HTTPDoWithCustomValidationE(t testing.TestingT, method string, url string, body io.Reader, headers map[string]string, validateResponse func(int, string) bool, tlsConfig *tls.Config) error
HTTPDoWithCustomValidationE performs the given HTTP method on the given URL and validate the returned status code and body using the given function.
func HTTPDoWithCustomValidationWithOptions ¶ added in v0.41.1
func HTTPDoWithCustomValidationWithOptions(t testing.TestingT, options HttpDoOptions, validateResponse func(int, string) bool)
HTTPDoWithCustomValidationWithOptions performs the given HTTP method on the given URL and validate the returned status code and body using the given function.
func HTTPDoWithCustomValidationWithOptionsE ¶ added in v0.41.1
func HTTPDoWithCustomValidationWithOptionsE(t testing.TestingT, options HttpDoOptions, validateResponse func(int, string) bool) error
HTTPDoWithCustomValidationWithOptionsE performs the given HTTP method on the given URL and validate the returned status code and body using the given function.
func HTTPDoWithOptions ¶ added in v0.41.1
func HTTPDoWithOptions( t testing.TestingT, options HttpDoOptions, ) (int, string)
HTTPDoWithOptions performs the given HTTP method on the given URL and return the HTTP status code and body. If there's any error, fail the test.
func HTTPDoWithOptionsE ¶ added in v0.41.1
HTTPDoWithOptionsE performs the given HTTP method on the given URL and return the HTTP status code, body, and any error.
func HTTPDoWithRetry ¶ added in v0.18.5
func HTTPDoWithRetry( t testing.TestingT, method string, url string, body []byte, headers map[string]string, expectedStatus int, retries int, sleepBetweenRetries time.Duration, tlsConfig *tls.Config, ) string
HTTPDoWithRetry repeatedly performs the given HTTP method on the given URL until the given status code and body are returned or until max retries has been exceeded. The function compares the expected status code against the received one and fails if they don't match.
func HTTPDoWithRetryE ¶ added in v0.18.5
func HTTPDoWithRetryE( t testing.TestingT, method string, url string, body []byte, headers map[string]string, expectedStatus int, retries int, sleepBetweenRetries time.Duration, tlsConfig *tls.Config, ) (string, error)
HTTPDoWithRetryE repeatedly performs the given HTTP method on the given URL until the given status code and body are returned or until max retries has been exceeded. The function compares the expected status code against the received one and fails if they don't match.
func HTTPDoWithRetryWithOptions ¶ added in v0.41.1
func HTTPDoWithRetryWithOptions( t testing.TestingT, options HttpDoOptions, expectedStatus int, retries int, sleepBetweenRetries time.Duration, ) string
HTTPDoWithRetryWithOptions repeatedly performs the given HTTP method on the given URL until the given status code and body are returned or until max retries has been exceeded. The function compares the expected status code against the received one and fails if they don't match.
func HTTPDoWithRetryWithOptionsE ¶ added in v0.41.1
func HTTPDoWithRetryWithOptionsE( t testing.TestingT, options HttpDoOptions, expectedStatus int, retries int, sleepBetweenRetries time.Duration, ) (string, error)
HTTPDoWithRetryWithOptionsE repeatedly performs the given HTTP method on the given URL until the given status code and body are returned or until max retries has been exceeded. The function compares the expected status code against the received one and fails if they don't match.
func HTTPDoWithValidation ¶ added in v0.18.5
func HTTPDoWithValidation(t testing.TestingT, method string, url string, body io.Reader, headers map[string]string, expectedStatusCode int, expectedBody string, tlsConfig *tls.Config)
HTTPDoWithValidation performs the given HTTP method on the given URL and verify that you get back the expected status code and body. If either doesn't match, fail the test.
func HTTPDoWithValidationE ¶ added in v0.18.5
func HTTPDoWithValidationE(t testing.TestingT, method string, url string, body io.Reader, headers map[string]string, expectedStatusCode int, expectedBody string, tlsConfig *tls.Config) error
HTTPDoWithValidationE performs the given HTTP method on the given URL and verify that you get back the expected status code and body. If either doesn't match, return an error.
func HTTPDoWithValidationRetry ¶ added in v0.18.5
func HTTPDoWithValidationRetry( t testing.TestingT, method string, url string, body []byte, headers map[string]string, expectedStatus int, expectedBody string, retries int, sleepBetweenRetries time.Duration, tlsConfig *tls.Config, )
HTTPDoWithValidationRetry repeatedly performs the given HTTP method on the given URL until the given status code and body are returned or until max retries has been exceeded.
func HTTPDoWithValidationRetryE ¶ added in v0.18.5
func HTTPDoWithValidationRetryE( t testing.TestingT, method string, url string, body []byte, headers map[string]string, expectedStatus int, expectedBody string, retries int, sleepBetweenRetries time.Duration, tlsConfig *tls.Config, ) error
HTTPDoWithValidationRetryE repeatedly performs the given HTTP method on the given URL until the given status code and body are returned or until max retries has been exceeded.
func HTTPDoWithValidationRetryWithOptions ¶ added in v0.41.1
func HTTPDoWithValidationRetryWithOptions( t testing.TestingT, options HttpDoOptions, expectedStatus int, expectedBody string, retries int, sleepBetweenRetries time.Duration, )
HTTPDoWithValidationRetryWithOptions repeatedly performs the given HTTP method on the given URL until the given status code and body are returned or until max retries has been exceeded.
func HTTPDoWithValidationRetryWithOptionsE ¶ added in v0.41.1
func HTTPDoWithValidationRetryWithOptionsE( t testing.TestingT, options HttpDoOptions, expectedStatus int, expectedBody string, retries int, sleepBetweenRetries time.Duration, ) error
HTTPDoWithValidationRetryWithOptionsE repeatedly performs the given HTTP method on the given URL until the given status code and body are returned or until max retries has been exceeded.
func HTTPDoWithValidationWithOptions ¶ added in v0.41.1
func HTTPDoWithValidationWithOptions(t testing.TestingT, options HttpDoOptions, expectedStatusCode int, expectedBody string)
HTTPDoWithValidationWithOptions performs the given HTTP method on the given URL and verify that you get back the expected status code and body. If either doesn't match, fail the test.
func HTTPDoWithValidationWithOptionsE ¶ added in v0.41.1
func HTTPDoWithValidationWithOptionsE(t testing.TestingT, options HttpDoOptions, expectedStatusCode int, expectedBody string) error
HTTPDoWithValidationWithOptionsE performs the given HTTP method on the given URL and verify that you get back the expected status code and body. If either doesn't match, return an error.
func HttpGet ¶
HttpGet performs an HTTP GET, with an optional pointer to a custom TLS configuration, on the given URL and return the HTTP status code and body. If there's any error, fail the test.
func HttpGetE ¶
HttpGetE performs an HTTP GET, with an optional pointer to a custom TLS configuration, on the given URL and return the HTTP status code, body, and any error.
func HttpGetWithCustomValidation ¶
func HttpGetWithCustomValidation(t testing.TestingT, url string, tlsConfig *tls.Config, validateResponse func(int, string) bool)
HttpGetWithCustomValidation performs an HTTP GET on the given URL and validate the returned status code and body using the given function.
func HttpGetWithCustomValidationE ¶
func HttpGetWithCustomValidationE(t testing.TestingT, url string, tlsConfig *tls.Config, validateResponse func(int, string) bool) error
HttpGetWithCustomValidationE performs an HTTP GET on the given URL and validate the returned status code and body using the given function.
func HttpGetWithCustomValidationWithOptions ¶ added in v0.41.1
func HttpGetWithCustomValidationWithOptions(t testing.TestingT, options HttpGetOptions, validateResponse func(int, string) bool)
HttpGetWithCustomValidationWithOptions performs an HTTP GET on the given URL and validate the returned status code and body using the given function.
func HttpGetWithCustomValidationWithOptionsE ¶ added in v0.41.1
func HttpGetWithCustomValidationWithOptionsE(t testing.TestingT, options HttpGetOptions, validateResponse func(int, string) bool) error
HttpGetWithCustomValidationWithOptionsE performs an HTTP GET on the given URL and validate the returned status code and body using the given function.
func HttpGetWithOptions ¶ added in v0.41.1
func HttpGetWithOptions(t testing.TestingT, options HttpGetOptions) (int, string)
HttpGetWithOptions performs an HTTP GET, with an optional pointer to a custom TLS configuration, on the given URL and return the HTTP status code and body. If there's any error, fail the test.
func HttpGetWithOptionsE ¶ added in v0.41.1
HttpGetWithOptionsE performs an HTTP GET, with an optional pointer to a custom TLS configuration, on the given URL and return the HTTP status code, body, and any error.
func HttpGetWithRetry ¶
func HttpGetWithRetry(t testing.TestingT, url string, tlsConfig *tls.Config, expectedStatus int, expectedBody string, retries int, sleepBetweenRetries time.Duration)
HttpGetWithRetry repeatedly performs an HTTP GET on the given URL until the given status code and body are returned or until max retries has been exceeded.
func HttpGetWithRetryE ¶
func HttpGetWithRetryE(t testing.TestingT, url string, tlsConfig *tls.Config, expectedStatus int, expectedBody string, retries int, sleepBetweenRetries time.Duration) error
HttpGetWithRetryE repeatedly performs an HTTP GET on the given URL until the given status code and body are returned or until max retries has been exceeded.
func HttpGetWithRetryWithCustomValidation ¶
func HttpGetWithRetryWithCustomValidation(t testing.TestingT, url string, tlsConfig *tls.Config, retries int, sleepBetweenRetries time.Duration, validateResponse func(int, string) bool)
HttpGetWithRetryWithCustomValidation repeatedly performs an HTTP GET on the given URL until the given validation function returns true or max retries has been exceeded.
func HttpGetWithRetryWithCustomValidationE ¶
func HttpGetWithRetryWithCustomValidationE(t testing.TestingT, url string, tlsConfig *tls.Config, retries int, sleepBetweenRetries time.Duration, validateResponse func(int, string) bool) error
HttpGetWithRetryWithCustomValidationE repeatedly performs an HTTP GET on the given URL until the given validation function returns true or max retries has been exceeded.
func HttpGetWithRetryWithCustomValidationWithOptions ¶ added in v0.41.1
func HttpGetWithRetryWithCustomValidationWithOptions(t testing.TestingT, options HttpGetOptions, retries int, sleepBetweenRetries time.Duration, validateResponse func(int, string) bool)
HttpGetWithRetryWithCustomValidationWithOptions repeatedly performs an HTTP GET on the given URL until the given validation function returns true or max retries has been exceeded.
func HttpGetWithRetryWithCustomValidationWithOptionsE ¶ added in v0.41.1
func HttpGetWithRetryWithCustomValidationWithOptionsE(t testing.TestingT, options HttpGetOptions, retries int, sleepBetweenRetries time.Duration, validateResponse func(int, string) bool) error
HttpGetWithRetryWithCustomValidationWithOptionsE repeatedly performs an HTTP GET on the given URL until the given validation function returns true or max retries has been exceeded.
func HttpGetWithRetryWithOptions ¶ added in v0.41.1
func HttpGetWithRetryWithOptions(t testing.TestingT, options HttpGetOptions, expectedStatus int, expectedBody string, retries int, sleepBetweenRetries time.Duration)
HttpGetWithRetryWithOptions repeatedly performs an HTTP GET on the given URL until the given status code and body are returned or until max retries has been exceeded.
func HttpGetWithRetryWithOptionsE ¶ added in v0.41.1
func HttpGetWithRetryWithOptionsE(t testing.TestingT, options HttpGetOptions, expectedStatus int, expectedBody string, retries int, sleepBetweenRetries time.Duration) error
HttpGetWithRetryWithOptionsE repeatedly performs an HTTP GET on the given URL until the given status code and body are returned or until max retries has been exceeded.
func HttpGetWithValidation ¶
func HttpGetWithValidation(t testing.TestingT, url string, tlsConfig *tls.Config, expectedStatusCode int, expectedBody string)
HttpGetWithValidation performs an HTTP GET on the given URL and verify that you get back the expected status code and body. If either doesn't match, fail the test.
func HttpGetWithValidationE ¶
func HttpGetWithValidationE(t testing.TestingT, url string, tlsConfig *tls.Config, expectedStatusCode int, expectedBody string) error
HttpGetWithValidationE performs an HTTP GET on the given URL and verify that you get back the expected status code and body. If either doesn't match, return an error.
func HttpGetWithValidationWithOptions ¶ added in v0.41.1
func HttpGetWithValidationWithOptions(t testing.TestingT, options HttpGetOptions, expectedStatusCode int, expectedBody string)
HttpGetWithValidationWithOptions performs an HTTP GET on the given URL and verify that you get back the expected status code and body. If either doesn't match, fail the test.
func HttpGetWithValidationWithOptionsE ¶ added in v0.41.1
func HttpGetWithValidationWithOptionsE(t testing.TestingT, options HttpGetOptions, expectedStatusCode int, expectedBody string) error
HttpGetWithValidationWithOptionsE performs an HTTP GET on the given URL and verify that you get back the expected status code and body. If either doesn't match, return an error.
func RunDummyServer ¶
RunDummyServer runs a dummy HTTP server on a unique port that will return the given text. Returns the Listener for the server, the port it's listening on, or an error if something went wrong while trying to start the listener. Make sure to call the Close() method on the Listener when you're done!
func RunDummyServerE ¶
RunDummyServerE runs a dummy HTTP server on a unique port that will return the given text. Returns the Listener for the server, the port it's listening on, or an error if something went wrong while trying to start the listener. Make sure to call the Close() method on the Listener when you're done!
func RunDummyServerWithHandlers ¶ added in v0.18.5
func RunDummyServerWithHandlers(t testing.TestingT, handlers map[string]func(http.ResponseWriter, *http.Request)) (net.Listener, int)
RunDummyServerWithHandlers runs a dummy HTTP server on a unique port that will serve given handlers. Returns the Listener for the server, the port it's listening on, or an error if something went wrong while trying to start the listener. Make sure to call the Close() method on the Listener when you're done!
func RunDummyServerWithHandlersE ¶ added in v0.18.5
func RunDummyServerWithHandlersE(t testing.TestingT, handlers map[string]func(http.ResponseWriter, *http.Request)) (net.Listener, int, error)
RunDummyServerWithHandlersE runs a dummy HTTP server on a unique port that will server given handlers. Returns the Listener for the server, the port it's listening on, or an error if something went wrong while trying to start the listener. Make sure to call the Close() method on the Listener when you're done!
Types ¶
type GetResponse ¶ added in v0.13.16
type HttpDoOptions ¶ added in v0.41.1
type HttpGetOptions ¶ added in v0.41.1
type ValidationFunctionFailed ¶
ValidationFunctionFailed is an error that occurs if a validation function fails.
func (ValidationFunctionFailed) Error ¶
func (err ValidationFunctionFailed) Error() string