comparator

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

func NewComparator

func NewComparator() *Builder

NewComparator is the builder initiator. Always use the builder to create a Comparator as this will set the default options.

func (*Builder) Build

func (builder *Builder) Build() *Comparator

func (*Builder) Logger

func (builder *Builder) Logger(logger *slog.Logger) *Builder

func (*Builder) Recorder

func (builder *Builder) Recorder(recorder recorder.Recorder) *Builder

Recorder to be used. Default is the NoopRecorder.

func (*Builder) StrictObjectCheck

func (builder *Builder) StrictObjectCheck(check bool) *Builder

StrictObjectCheck determines if the Comparator will do a strict check on object fields. If set to 'true', the following checks will be done: - actual JSON has the same number of fields - actual JSON has extra unexpected fields

Default is 'true'.

type Comparator

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

Comparator used for comparing JSON structures. It returns detailed errors about how the compared structures do not match. The errors may also contain JSON paths that point to the fields discovered.

Always create a comparator using the NewComparator builder.

The comparator does not fail fast and goes over the entire structure for validation. It is goroutine safe.

func (*Comparator) Compare

func (comparator *Comparator) Compare(expected []byte, actual []byte) (string, error)

Jump to

Keyboard shortcuts

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