internaltest
v1.47.0
Documentation
pkg.go.dev ↗Package internaltest provides testing functionality.
Types
TextMapCarrier
type TextMapCarrier struct {
// contains filtered or unexported fields
}
TextMapCarrier is a storage medium for a TextMapPropagator used in testing. The methods of a TextMapCarrier are concurrent safe.
NewTextMapCarrier
func NewTextMapCarrier(data map[string]string) *TextMapCarrier
NewTextMapCarrier returns a new *TextMapCarrier populated with data.
TextMapCarrier.Get
func (c *TextMapCarrier) Get(key string) string
Get returns the value associated with the passed key.
TextMapCarrier.GotKey
func (c *TextMapCarrier) GotKey(t *testing.T, key string) bool
GotKey tests if c.Get has been called for key.
TextMapCarrier.GotN
func (c *TextMapCarrier) GotN(t *testing.T, n int) bool
GotN tests if n calls to c.Get have been made.
TextMapCarrier.Keys
func (c *TextMapCarrier) Keys() []string
Keys returns the keys for which this carrier has a value.
TextMapCarrier.Reset
func (c *TextMapCarrier) Reset(data map[string]string)
Reset zeros out the recording state and sets the carried values to data.
TextMapCarrier.Set
func (c *TextMapCarrier) Set(key, value string)
Set stores the key-value pair.
TextMapCarrier.SetKeyValue
func (c *TextMapCarrier) SetKeyValue(t *testing.T, key, value string) bool
SetKeyValue tests if c.Set has been called for the key-value pair.
TextMapCarrier.SetN
func (c *TextMapCarrier) SetN(t *testing.T, n int) bool
SetN tests if n calls to c.Set have been made.
TextMapPropagator
type TextMapPropagator struct {
// contains filtered or unexported fields
}
TextMapPropagator is a propagation.TextMapPropagator used for testing.
NewTextMapPropagator
func NewTextMapPropagator(name string) *TextMapPropagator
NewTextMapPropagator returns a new TextMapPropagator for testing. It will use name as the key it injects into a TextMapCarrier when Inject is called.
TextMapPropagator.Extract
func (p *TextMapPropagator) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context
Extract reads cross-cutting concerns for p from carrier into ctx.
TextMapPropagator.ExtractedN
func (p *TextMapPropagator) ExtractedN(t *testing.T, ctx context.Context, n int) bool
ExtractedN tests if p has made n extractions from the lineage of ctx. nolint (context is not first arg)
TextMapPropagator.Fields
func (p *TextMapPropagator) Fields() []string
Fields returns the name of p as the key who's value is set with Inject.
TextMapPropagator.Inject
func (p *TextMapPropagator) Inject(ctx context.Context, carrier propagation.TextMapCarrier)
Inject sets cross-cutting concerns for p from ctx into carrier.
TextMapPropagator.InjectedN
func (p *TextMapPropagator) InjectedN(t *testing.T, carrier *TextMapCarrier, n uint64) bool
InjectedN tests if p has made n injections to carrier.