testutil

package
v0.0.0-...-278bcbb Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package testutil provides types and methods facilitating testing TraceViz response construction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareDataResponses

func CompareDataResponses(t *testing.T, got any, want any) error

CompareDataResponses compares the provided got and want values, which must be either *util.DataResponseBuilder or *util.Data. If the two compare equal, returns nil. If they do not compare equal, raises an error on the provided testing.T object. If another problem is encountered, returns it as an error.

func CompareResponses

func CompareResponses(t *testing.T, buildGotIf any, buildWantIf any) error

CompareResponses is a test helper for TraceViz data sources and data helpers. It compares test output from the system under test with desired output. Both outputs are produced by callbacks accepting either a util.DataBuilder or a TestDataBuilder.

Types

type TestDataBuilder

type TestDataBuilder interface {
	With(updates ...util.PropertyUpdate) TestDataBuilder
	Child() TestDataBuilder
	AndChild() TestDataBuilder
	Parent() TestDataBuilder
}

TestDataBuilder is implemented by types that can assemble TraceViz responses in tests.

type UpdateComparator

type UpdateComparator struct {
	// contains filtered or unexported fields
}

UpdateComparator facilitates testing of PropertyUpdates, ensuring that a 'got' set of PropertyUpdates-under-test yields the same transformation as a provided 'want' set of PropertyUpdates.

func NewUpdateComparator

func NewUpdateComparator() *UpdateComparator

NewUpdateComparator returns a new, empty UpdateComparator.

func (*UpdateComparator) Compare

func (uc *UpdateComparator) Compare(t *testing.T) (string, bool)

Compare the receiver's 'got' and 'want' PropertyUpdates, returning a difference message (empty if no difference) and a boolean indicating whether the two are different (true) or not (false). Repeated-field ordering must be preserved, but string-table ordering need not be preserved.

func (*UpdateComparator) WithTestUpdates

func (uc *UpdateComparator) WithTestUpdates(got ...util.PropertyUpdate) *UpdateComparator

WithTestUpdates specifies the receiver's set of PropertyUpdates-under-test.

func (*UpdateComparator) WithWantUpdates

func (uc *UpdateComparator) WithWantUpdates(want ...util.PropertyUpdate) *UpdateComparator

WithWantUpdates specifies a set of PropertyUpdates that should yield the same result as the receiver's 'WithTestUpdate'.

Jump to

Keyboard shortcuts

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