http_helper

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 15 Imported by: 23

Documentation

Overview

Package http_helper contains helpers to interact with deployed resources through HTTP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContinuouslyCheckURLContext added in v1.0.0

func ContinuouslyCheckURLContext(
	t testing.TestingT,
	ctx context.Context,
	url string,
	stopChecking <-chan bool,
	sleepBetweenChecks time.Duration,
) (*sync.WaitGroup, <-chan GetResponse)

ContinuouslyCheckURLContext continuously checks the given URL at the specified interval until the stopChecking channel receives a signal to stop. It returns 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. The channel has a buffer of 1000 entries, after which it will start to drop send events. The provided context is used for each HTTP request made during checking.

func ContinuouslyCheckUrl deprecated added in v0.13.16

func ContinuouslyCheckUrl(
	t testing.TestingT,
	url string,
	stopChecking <-chan bool,
	sleepBetweenChecks time.Duration,
) (*sync.WaitGroup, <-chan GetResponse)

ContinuouslyCheckUrl continuously checks the given URL at the specified interval until the stopChecking channel receives a signal to stop.

Deprecated: Use ContinuouslyCheckURLContext instead.

func HTTPDo deprecated 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.

Deprecated: Use HTTPDoContext instead.

func HTTPDoContext added in v1.0.0

func HTTPDoContext(
	t testing.TestingT, ctx context.Context, method string, url string, body io.Reader,
	headers map[string]string, tlsConfig *tls.Config,
) (int, string)

HTTPDoContext performs the given HTTP method on the given URL and returns the HTTP status code and body. The provided context is used for the HTTP request. If there's any error, fail the test.

func HTTPDoContextE added in v1.0.0

func HTTPDoContextE(
	t testing.TestingT, ctx context.Context, method string, url string, body io.Reader,
	headers map[string]string, tlsConfig *tls.Config,
) (int, string, error)

HTTPDoContextE performs the given HTTP method on the given URL and returns the HTTP status code, body, and any error. The provided context is used for the HTTP request.

func HTTPDoE deprecated 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.

Deprecated: Use HTTPDoContextE instead.

func HTTPDoWithCustomValidation deprecated 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.

Deprecated: Use HTTPDoWithCustomValidationContext instead.

func HTTPDoWithCustomValidationContext added in v1.0.0

func HTTPDoWithCustomValidationContext(t testing.TestingT, ctx context.Context, method string, url string, body io.Reader, headers map[string]string, validateResponse func(int, string) bool, tlsConfig *tls.Config)

HTTPDoWithCustomValidationContext performs the given HTTP method on the given URL and validates the returned status code and body using the given function. The provided context is used for the HTTP request.

func HTTPDoWithCustomValidationContextE added in v1.0.0

func HTTPDoWithCustomValidationContextE(t testing.TestingT, ctx context.Context, method string, url string, body io.Reader, headers map[string]string, validateResponse func(int, string) bool, tlsConfig *tls.Config) error

HTTPDoWithCustomValidationContextE performs the given HTTP method on the given URL and validates the returned status code and body using the given function. The provided context is used for the HTTP request.

func HTTPDoWithCustomValidationE deprecated 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.

Deprecated: Use HTTPDoWithCustomValidationContextE instead.

func HTTPDoWithCustomValidationWithOptions added in v0.40.11

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.40.11

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.40.11

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.40.11

func HTTPDoWithOptionsE(
	t testing.TestingT, options HttpDoOptions,
) (int, string, error)

HTTPDoWithOptionsE performs the given HTTP method on the given URL and return the HTTP status code, body, and any error.

func HTTPDoWithRetry deprecated 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.

Deprecated: Use HTTPDoWithRetryContext instead.

func HTTPDoWithRetryContext added in v1.0.0

func HTTPDoWithRetryContext(
	t testing.TestingT, ctx context.Context, method string, url string,
	body []byte, headers map[string]string, expectedStatus int,
	retries int, sleepBetweenRetries time.Duration, tlsConfig *tls.Config,
) string

HTTPDoWithRetryContext repeatedly performs the given HTTP method on the given URL until the given status code is returned or until max retries has been exceeded. The provided context is used for each HTTP request. The function compares the expected status code against the received one and fails if they don't match.

func HTTPDoWithRetryContextE added in v1.0.0

func HTTPDoWithRetryContextE(
	t testing.TestingT, ctx context.Context, method string, url string,
	body []byte, headers map[string]string, expectedStatus int,
	retries int, sleepBetweenRetries time.Duration, tlsConfig *tls.Config,
) (string, error)

HTTPDoWithRetryContextE repeatedly performs the given HTTP method on the given URL until the given status code is returned or until max retries has been exceeded. The provided context is used for each HTTP request. The function compares the expected status code against the received one and fails if they don't match.

func HTTPDoWithRetryE deprecated 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.

Deprecated: Use HTTPDoWithRetryContextE instead.

func HTTPDoWithRetryWithOptions added in v0.40.11

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.40.11

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 deprecated 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.

Deprecated: Use HTTPDoWithValidationContext instead.

func HTTPDoWithValidationContext added in v1.0.0

func HTTPDoWithValidationContext(t testing.TestingT, ctx context.Context, method string, url string, body io.Reader, headers map[string]string, expectedStatusCode int, expectedBody string, tlsConfig *tls.Config)

HTTPDoWithValidationContext performs the given HTTP method on the given URL and verifies that the response has the expected status code and body. The provided context is used for the HTTP request. If either doesn't match, fail the test.

func HTTPDoWithValidationContextE added in v1.0.0

func HTTPDoWithValidationContextE(t testing.TestingT, ctx context.Context, method string, url string, body io.Reader, headers map[string]string, expectedStatusCode int, expectedBody string, tlsConfig *tls.Config) error

HTTPDoWithValidationContextE performs the given HTTP method on the given URL and verifies that the response has the expected status code and body. The provided context is used for the HTTP request. If either doesn't match, return an error.

func HTTPDoWithValidationE deprecated 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.

Deprecated: Use HTTPDoWithValidationContextE instead.

func HTTPDoWithValidationRetry deprecated 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.

Deprecated: Use HTTPDoWithValidationRetryContext instead.

func HTTPDoWithValidationRetryContext added in v1.0.0

func HTTPDoWithValidationRetryContext(
	t testing.TestingT, ctx context.Context, method string, url string,
	body []byte, headers map[string]string, expectedStatus int,
	expectedBody string, retries int, sleepBetweenRetries time.Duration, tlsConfig *tls.Config,
)

HTTPDoWithValidationRetryContext 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 provided context is used for each HTTP request.

func HTTPDoWithValidationRetryContextE added in v1.0.0

func HTTPDoWithValidationRetryContextE(
	t testing.TestingT, ctx context.Context, method string, url string,
	body []byte, headers map[string]string, expectedStatus int,
	expectedBody string, retries int, sleepBetweenRetries time.Duration, tlsConfig *tls.Config,
) error

HTTPDoWithValidationRetryContextE 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 provided context is used for each HTTP request.

func HTTPDoWithValidationRetryE deprecated 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.

Deprecated: Use HTTPDoWithValidationRetryContextE instead.

func HTTPDoWithValidationRetryWithOptions added in v0.40.11

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.40.11

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.40.11

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.40.11

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 HTTPGetContext added in v1.0.0

func HTTPGetContext(t testing.TestingT, ctx context.Context, url string, tlsConfig *tls.Config) (int, string)

HTTPGetContext performs an HTTP GET on the given URL with an optional custom TLS configuration and returns the HTTP status code and body. The provided context is used for the HTTP request. If there's any error, fail the test.

func HTTPGetContextE added in v1.0.0

func HTTPGetContextE(t testing.TestingT, ctx context.Context, url string, tlsConfig *tls.Config) (int, string, error)

HTTPGetContextE performs an HTTP GET on the given URL with an optional custom TLS configuration and returns the HTTP status code, body, and any error. The provided context is used for the HTTP request.

func HTTPGetWithCustomValidationContext added in v1.0.0

func HTTPGetWithCustomValidationContext(t testing.TestingT, ctx context.Context, url string, tlsConfig *tls.Config, validateResponse func(int, string) bool)

HTTPGetWithCustomValidationContext performs an HTTP GET on the given URL and validates the returned status code and body using the given function. The provided context is used for the HTTP request.

func HTTPGetWithCustomValidationContextE added in v1.0.0

func HTTPGetWithCustomValidationContextE(t testing.TestingT, ctx context.Context, url string, tlsConfig *tls.Config, validateResponse func(int, string) bool) error

HTTPGetWithCustomValidationContextE performs an HTTP GET on the given URL and validates the returned status code and body using the given function. The provided context is used for the HTTP request.

func HTTPGetWithRetryContext added in v1.0.0

func HTTPGetWithRetryContext(t testing.TestingT, ctx context.Context, url string, tlsConfig *tls.Config, expectedStatus int, expectedBody string, retries int, sleepBetweenRetries time.Duration)

HTTPGetWithRetryContext 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. The provided context is used for each HTTP request.

func HTTPGetWithRetryContextE added in v1.0.0

func HTTPGetWithRetryContextE(t testing.TestingT, ctx context.Context, url string, tlsConfig *tls.Config, expectedStatus int, expectedBody string, retries int, sleepBetweenRetries time.Duration) error

HTTPGetWithRetryContextE 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. The provided context is used for each HTTP request.

func HTTPGetWithRetryWithCustomValidationContext added in v1.0.0

func HTTPGetWithRetryWithCustomValidationContext(t testing.TestingT, ctx context.Context, url string, tlsConfig *tls.Config, retries int, sleepBetweenRetries time.Duration, validateResponse func(int, string) bool)

HTTPGetWithRetryWithCustomValidationContext repeatedly performs an HTTP GET on the given URL until the given validation function returns true or max retries has been exceeded. The provided context is used for each HTTP request.

func HTTPGetWithRetryWithCustomValidationContextE added in v1.0.0

func HTTPGetWithRetryWithCustomValidationContextE(t testing.TestingT, ctx context.Context, url string, tlsConfig *tls.Config, retries int, sleepBetweenRetries time.Duration, validateResponse func(int, string) bool) error

HTTPGetWithRetryWithCustomValidationContextE repeatedly performs an HTTP GET on the given URL until the given validation function returns true or max retries has been exceeded. The provided context is used for each HTTP request.

func HTTPGetWithValidationContext added in v1.0.0

func HTTPGetWithValidationContext(t testing.TestingT, ctx context.Context, url string, tlsConfig *tls.Config, expectedStatusCode int, expectedBody string)

HTTPGetWithValidationContext performs an HTTP GET on the given URL and verifies that the response has the expected status code and body. The provided context is used for the HTTP request. If either doesn't match, fail the test.

func HTTPGetWithValidationContextE added in v1.0.0

func HTTPGetWithValidationContextE(t testing.TestingT, ctx context.Context, url string, tlsConfig *tls.Config, expectedStatusCode int, expectedBody string) error

HTTPGetWithValidationContextE performs an HTTP GET on the given URL and verifies that the response has the expected status code and body. The provided context is used for the HTTP request. If either doesn't match, return an error.

func HttpGet deprecated

func HttpGet(t testing.TestingT, url string, tlsConfig *tls.Config) (int, string)

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.

Deprecated: Use HTTPGetContext instead.

func HttpGetE deprecated

func HttpGetE(t testing.TestingT, url string, tlsConfig *tls.Config) (int, string, error)

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.

Deprecated: Use HTTPGetContextE instead.

func HttpGetWithCustomValidation deprecated

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.

Deprecated: Use HTTPGetWithCustomValidationContext instead.

func HttpGetWithCustomValidationE deprecated

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.

Deprecated: Use HTTPGetWithCustomValidationContextE instead.

func HttpGetWithCustomValidationWithOptions added in v0.40.11

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.40.11

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.40.11

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.40.11

func HttpGetWithOptionsE(t testing.TestingT, options HttpGetOptions) (int, string, error)

HttpGetWithOptionsE performs an HTTP GET on the given URL with the given options and returns the HTTP status code, body, and any error.

func HttpGetWithRetry deprecated

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.

Deprecated: Use HTTPGetWithRetryContext instead.

func HttpGetWithRetryE deprecated

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.

Deprecated: Use HTTPGetWithRetryContextE instead.

func HttpGetWithRetryWithCustomValidation deprecated

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.

Deprecated: Use HTTPGetWithRetryWithCustomValidationContext instead.

func HttpGetWithRetryWithCustomValidationE deprecated

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.

Deprecated: Use HTTPGetWithRetryWithCustomValidationContextE instead.

func HttpGetWithRetryWithCustomValidationWithOptions added in v0.40.11

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.40.11

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.40.11

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.40.11

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 deprecated

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.

Deprecated: Use HTTPGetWithValidationContext instead.

func HttpGetWithValidationE deprecated

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.

Deprecated: Use HTTPGetWithValidationContextE instead.

func HttpGetWithValidationWithOptions added in v0.40.11

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.40.11

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 deprecated

func RunDummyServer(t testing.TestingT, text string) (net.Listener, int)

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!

Deprecated: Use RunDummyServerContext instead.

func RunDummyServerContext added in v1.0.0

func RunDummyServerContext(t testing.TestingT, ctx context.Context, text string) (net.Listener, int)

RunDummyServerContext 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. The provided context is used when establishing the network listener. Make sure to call the Close() method on the Listener when you're done!

func RunDummyServerContextE added in v1.0.0

func RunDummyServerContextE(t testing.TestingT, ctx context.Context, text string) (net.Listener, int, error)

RunDummyServerContextE 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. The provided context is used when establishing the network listener. Make sure to call the Close() method on the Listener when you're done!

func RunDummyServerE deprecated

func RunDummyServerE(t testing.TestingT, text string) (net.Listener, int, error)

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!

Deprecated: Use RunDummyServerContextE instead.

func RunDummyServerWithHandlers deprecated 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 the 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!

Deprecated: Use RunDummyServerWithHandlersContext instead.

func RunDummyServerWithHandlersContext added in v1.0.0

func RunDummyServerWithHandlersContext(t testing.TestingT, ctx context.Context, handlers map[string]func(http.ResponseWriter, *http.Request)) (net.Listener, int)

RunDummyServerWithHandlersContext runs a dummy HTTP server on a unique port that will serve the 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. The provided context is used when establishing the network listener. Make sure to call the Close() method on the Listener when you're done!

func RunDummyServerWithHandlersContextE added in v1.0.0

func RunDummyServerWithHandlersContextE(t testing.TestingT, ctx context.Context, handlers map[string]func(http.ResponseWriter, *http.Request)) (net.Listener, int, error)

RunDummyServerWithHandlersContextE runs a dummy HTTP server on a unique port that will serve the 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. The provided context is used when establishing the network listener. Make sure to call the Close() method on the Listener when you're done!

func RunDummyServerWithHandlersE deprecated 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 serve the 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!

Deprecated: Use RunDummyServerWithHandlersContextE instead.

Types

type GetResponse added in v0.13.16

type GetResponse struct {
	Body       string
	StatusCode int
}

GetResponse represents the response from an HTTP GET request.

type HttpDoOptions added in v0.40.11

type HttpDoOptions struct {
	// Context for the HTTP request. If nil, context.Background() is used.
	Context   context.Context
	Body      io.Reader
	Headers   map[string]string
	TlsConfig *tls.Config //nolint:staticcheck,revive // preserving existing field name
	Method    string
	Url       string //nolint:staticcheck,revive // preserving existing field name
	Timeout   int
}

HttpDoOptions defines options for HTTP requests using an arbitrary method.

type HttpGetOptions added in v0.40.11

type HttpGetOptions struct {
	// Context for the HTTP request. If nil, context.Background() is used.
	Context   context.Context
	TlsConfig *tls.Config //nolint:staticcheck,revive // preserving existing field name
	Url       string      //nolint:staticcheck,revive // preserving existing field name
	Timeout   int
}

HttpGetOptions defines options for HTTP GET requests.

type ValidationFunctionFailed

type ValidationFunctionFailed struct {
	Url    string //nolint:staticcheck // preserving existing field name
	Body   string
	Status int
}

ValidationFunctionFailed is an error that occurs if a validation function fails.

func (ValidationFunctionFailed) Error

func (err ValidationFunctionFailed) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL