Documentation ¶
Overview ¶
Package assert provides a set of helper functions to assert conditions in OTLP Arrow tests.
Index ¶
- func CanonicalMapID(object map[string]interface{}) string
- func CanonicalObjectID(object interface{}) string
- func CanonicalSliceID(slice []interface{}) string
- func CanonicalSliceMapID(slice []map[string]interface{}) string
- func Equiv(t Testing, expected []json.Marshaler, actual []json.Marshaler)
- func EquivFromBytes(t Testing, expected []byte, actual []byte)
- func JSONCanonicalEq(t Testing, expected interface{}, actual interface{})
- func NotEquiv(t Testing, expected []json.Marshaler, actual []json.Marshaler)
- type StandaloneTest
- type StdUnitTest
- type Testing
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalMapID ¶
CanonicalMapID computes a unique ID for a map. Sort the keys to ensure a consistent order.
func CanonicalObjectID ¶
func CanonicalObjectID(object interface{}) string
CanonicalObjectID computes a unique ID for an object.
func CanonicalSliceID ¶
func CanonicalSliceID(slice []interface{}) string
CanonicalSliceID computes a unique ID for a slice.
func CanonicalSliceMapID ¶
CanonicalSliceMapID computes a unique ID for a slice of maps.
func Equiv ¶
Equiv asserts that two arrays of json.Marshaler are equivalent. Metrics, logs, and traces requests implement json.Marshaler and are considered equivalent if they have the same set of vPaths. A vPath is a path to a value in a json object. For example the vPath "resource.attributes.service.name=myservice" refers to the value "myservice" in the json object {"resource":{"attributes":{"service":{"name":"myservice"}}}}.
The structure of the expected and actual json objects does not need to be exactly the same. For example, the following json objects are considered equivalent: [{"resource":{"attributes":{"service":"myservice", "version":"1.0"}}}] [{"resource":{"attributes":{"service":"myservice"}}}, {"resource":{"attributes":{"version":"1.0"}}}]
This concept of equivalence is useful for testing the conversion OTLP to/from OTLP Arrow as this conversion doesn't necessarily preserve the structure of the original OTLP entity. Resource spans or scope spans can be split or merged during the conversion if the semantic is preserved.
func EquivFromBytes ¶
func JSONCanonicalEq ¶
func JSONCanonicalEq(t Testing, expected interface{}, actual interface{})
JSONCanonicalEq compares two JSON objects for equality after converting them to a canonical form. This is useful for comparing JSON objects that may have different key orders or array orders.
Types ¶
type StandaloneTest ¶
type StandaloneTest struct { }
StandaloneTest adapts the Equiv() method for a standard unit test.
func (*StandaloneTest) Equal ¶
func (a *StandaloneTest) Equal(expected, actual interface{}, msgAndArgs ...any) bool
func (*StandaloneTest) FailNow ¶
func (a *StandaloneTest) FailNow(failureMessage string, msgAndArgs ...any) bool
func (*StandaloneTest) Helper ¶
func (a *StandaloneTest) Helper()
func (*StandaloneTest) NoError ¶
func (a *StandaloneTest) NoError(err error, msgAndArgs ...any)
type StdUnitTest ¶
type StdUnitTest struct {
// contains filtered or unexported fields
}
StdUnitTest adapts the Equiv() method for a standard unit test.
func (*StdUnitTest) Equal ¶
func (a *StdUnitTest) Equal(expected, actual interface{}, msgAndArgs ...any) bool
func (*StdUnitTest) FailNow ¶
func (a *StdUnitTest) FailNow(failureMessage string, msgAndArgs ...any) bool
func (*StdUnitTest) Helper ¶
func (a *StdUnitTest) Helper()
func (*StdUnitTest) NoError ¶
func (a *StdUnitTest) NoError(err error, msgAndArgs ...any)
type Testing ¶
type Testing interface { Helper() FailNow(failureMessage string, msgAndArgs ...any) bool NoError(err error, msgAndArgs ...any) Equal(expected, actual interface{}, msgAndArgs ...any) bool }
Testing is an interface that makes `assert.Equiv` independent of the testing framework. It is then possible to use `assert.Equiv` in contexts where the testing framework is not available.
func NewStandaloneTest ¶
func NewStandaloneTest() Testing