eventtest

package
v0.0.0-...-fe59bbe Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: BSD-3-Clause Imports: 10 Imported by: 3

Documentation

Overview

Package eventtest supports logging events to a test. You can use NewContext to create a context that knows how to deliver telemetry events back to the test. You must use this context or a derived one anywhere you want telemetry to be correctly routed back to the test it was constructed with.

Index

Constants

View Source
const (
	TimeFormat = logfmt.TimeFormat

	LogfmtOutput = `` /* 872-byte string literal not displayed */

	LogfOutput = `` /* 1018-byte string literal not displayed */

)

Variables

View Source
var (
	A = Info{
		Name: "A",
		Msg:  "a",
		Msgf: "a where A=%d",
	}

	B = Info{
		Name: "B",
		Msg:  "b",
		Msgf: "b where B=%q",
	}
)
View Source
var InitialTime = func() time.Time {
	t, _ := time.Parse(logfmt.TimeFormat, "2020/03/05 14:27:48")
	return t
}()

Functions

func CmpOptions

func CmpOptions() []cmp.Option

func ExporterOptions

func ExporterOptions() *event.ExporterOptions

func NewContext

func NewContext(ctx context.Context, tb testing.TB) context.Context

NewContext returns a context you should use for the active test.

func RunBenchmark

func RunBenchmark(b *testing.B, ctx context.Context, hooks Hooks)

func TestAllocs

func TestAllocs(t *testing.T, f func(io.Writer) context.Context, hooks Hooks, expect int)

func TestBenchmark

func TestBenchmark(t *testing.T, f func(io.Writer) context.Context, hooks Hooks, expect string)

Types

type CaptureHandler

type CaptureHandler struct {
	Got []event.Event
}

func NewCapture

func NewCapture() (context.Context, *CaptureHandler)

func (*CaptureHandler) Event

func (*CaptureHandler) Reset

func (h *CaptureHandler) Reset()

type Hooks

type Hooks struct {
	AStart func(ctx context.Context, a int) context.Context
	AEnd   func(ctx context.Context)
	BStart func(ctx context.Context, b string) context.Context
	BEnd   func(ctx context.Context)
}

type Info

type Info struct {
	Name string
	Msg  string
	Msgf string
}

Jump to

Keyboard shortcuts

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