Documentation
¶
Overview ¶
Package testing provides functionality for use when conducting tests
Index ¶
- Constants
- Variables
- func BasicHTTPHandler(w http.ResponseWriter, _ *http.Request)
- func NewRecordingTracer(t testing.TB) (*tracing.Tracer, *tracetest.SpanRecorder)
- func NewTestInstance(configFile string, defaultPathConfigs func(*bo.Options) po.List, respCode int, ...) (*httptest.Server, *httptest.ResponseRecorder, *http.Request, *http.Client, ...)
- func NewTestPathConfig(o *bo.Options, defaultPathConfigs func(*bo.Options) po.List, urlPath string) *po.Options
- func NewTestRewriteInstructions() rewriter.RewriteInstructions
- func NewTestServer(responseCode int, responseBody string, headers map[string]string) *httptest.Server
- func NewTestTracer() *tracing.Tracer
- func NewTestWebClient() *http.Client
- func RequireNoSpanAttribute(t testing.TB, sr *tracetest.SpanRecorder, spanName, key string)
- func RequireSpanAttributes(t testing.TB, sr *tracetest.SpanRecorder, spanName string, ...)
Constants ¶
const ( // Epoch2020 is the epoch value representing 1 January 2020 00:00:00 UTC Epoch2020 int64 = 1577836800 // Provider Names PrometheusBackendProvider = providers.Prometheus PromSimBackendProvider = "promsim" RangeSimBackendProvider = "rangesim" RPCBackendProvider = providers.ReverseProxyCacheShort )
Variables ¶
var ErrTest = errors.New("test error")
ErrTest is a Test Error
var Time2020 = time.Unix(Epoch2020, 0)
Time2020 is the Time.Time representing 1 January 2020 00:00:00 UTC
Functions ¶
func BasicHTTPHandler ¶
func BasicHTTPHandler(w http.ResponseWriter, _ *http.Request)
BasicHTTPHandler is a basic HTTP Handler for use in unit e
func NewRecordingTracer ¶ added in v2.0.4
NewRecordingTracer returns a tracer and span recorder for assertions.
func NewTestInstance ¶
func NewTestInstance( configFile string, defaultPathConfigs func(*bo.Options) po.List, respCode int, respBody string, respHeaders map[string]string, backendProvider, urlPath, logLevel string, ) (*httptest.Server, *httptest.ResponseRecorder, *http.Request, *http.Client, error)
NewTestInstance will start a trickster
func NewTestPathConfig ¶
func NewTestPathConfig( o *bo.Options, defaultPathConfigs func(*bo.Options) po.List, urlPath string, ) *po.Options
NewTestPathConfig returns a path config based on the provided parameters
func NewTestRewriteInstructions ¶
func NewTestRewriteInstructions() rewriter.RewriteInstructions
NewTestRewriterInstructions returns a set of example Rewriter Instructions for use in unit testing
func NewTestServer ¶
func NewTestServer(responseCode int, responseBody string, headers map[string]string) *httptest.Server
NewTestServer returns a new httptest.Server that responds with the provided code, body and headers
func NewTestTracer ¶
NewTestTracer returns a standard out tracer for testing purposes
func NewTestWebClient ¶
NewTestWebClient returns a new *http.Client configured with reasonable defaults
func RequireNoSpanAttribute ¶ added in v2.0.4
func RequireNoSpanAttribute(t testing.TB, sr *tracetest.SpanRecorder, spanName, key string)
RequireNoSpanAttribute asserts that the most recently ended span named spanName does not have key.
func RequireSpanAttributes ¶ added in v2.0.4
func RequireSpanAttributes(t testing.TB, sr *tracetest.SpanRecorder, spanName string, want map[string]string)
RequireSpanAttributes asserts that the most recently ended span named spanName has all wanted attributes.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package albpool provides shared test helpers for constructing ALB pools, targets, and parent requests.
|
Package albpool provides shared test helpers for constructing ALB pools, targets, and parent requests. |
|
Package golden holds JSON-fixture helpers for tests that maintain testdata/ goldens.
|
Package golden holds JSON-fixture helpers for tests that maintain testdata/ goldens. |
|
timeseries
|
|
|
model
Package model is a test utility package that serializes between a *DataSet and the Prometheus HTTP API JSON Format
|
Package model is a test utility package that serializes between a *DataSet and the Prometheus HTTP API JSON Format |
|
Package tls provides functionality for use when conducting tests with TLS
|
Package tls provides functionality for use when conducting tests with TLS |
|
package writer represents a Test ResponseWriter for use in Unit Tests
|
package writer represents a Test ResponseWriter for use in Unit Tests |