comparator

package
v1.0.2-test Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareResponses

func CompareResponses(records1, records2 <-chan respreader.RespRecord, comparator Comparator, numComparisons int) <-chan RespDiff

CompareResponses compares responses from the given channels using the specified response comparator. You can limit the number of comparisons by using the n param.

Types

type Comparator

type Comparator interface {
	Compare(resp1, resp2 sender.Response) (map[string][]diffmatchpatch.Diff, error)
}

Comparator is responsible for performing comparison of two responses.

type DefaultComparator

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

func NewDefaultComparator

func NewDefaultComparator(ignoreOrder bool) DefaultComparator

func (DefaultComparator) Compare

func (c DefaultComparator) Compare(x, y sender.Response) (map[string][]diffmatchpatch.Diff, error)

type RespDiff

type RespDiff struct {
	Rec1  respreader.RespRecord
	Rec2  respreader.RespRecord
	Diffs map[string][]diffmatchpatch.Diff
}

RespDiff is the result of comparing two response records.

type ScriptComparator

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

func NewScriptComparator

func NewScriptComparator(script string, ignoreOrder bool) (ScriptComparator, error)

NewScriptComparator creates a new response comparator from the given JavaScript code. The script must have a function called 'compare' that accepts two responses and returns a map of diffs. The map of diffs can contain anything the user is interested in comparing. They can name keys as they want and use the 'diff' function to generate the diff.

func (ScriptComparator) Compare

func (c ScriptComparator) Compare(x, y sender.Response) (map[string][]diffmatchpatch.Diff, error)

Jump to

Keyboard shortcuts

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