parity

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package parity replays the shared test cases the manager's Node export writes into testdata/parity, and compares Go results with the Node ones.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AWSError

func AWSError(err error) error

AWSError is err as the AWS SDK returns a failed call: a recorded error becomes a *smithy.GenericAPIError (its code the name, its message the message), so the code under test reads it as it reads AWS's (awserr); any other error is returned as it is. The fakes of the AWS ports return AWSError(answers.Call(…)); Kubernetes ones keep their *kubernetes.Error.

func Equal

func Equal(t testing.TB, want, got json.RawMessage)

Equal fails t unless want and got are the same JSON: object key order is ignored and numbers are compared to a relative 1e-9.

Types

type Answers

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

Answers answers port calls from the recorded answers of a case.

func Recorded

func Recorded(t testing.TB, answers json.RawMessage) *Answers

Recorded reads a case's input.answers: {"<port>.<method>": [{"input", "output" or "error"}]}.

func (*Answers) Call

func (a *Answers) Call(port, method string, input any, out any) error

Call answers port.method(input) with the first recorded entry whose input equals input (JSON compared, key order ignored), decoded into out. A call with no entry returns an error; an entry carrying "error" returns it as a *RecordedError.

type Case

type Case struct {
	Name   string          `json:"name"`
	Input  json.RawMessage `json:"input"`
	Output json.RawMessage `json:"output"`
}

Case is one shared case: an input and the output the Node code gave.

type RecordedError

type RecordedError struct {
	Name    string `json:"name"`
	Message string `json:"message"`
	Status  int    `json:"status,omitempty"`
	Reason  string `json:"reason,omitempty"`
	Code    string `json:"code,omitempty"`
}

RecordedError is a failure the Node code saw from a port: the recorded "error" of an answer entry, {"name", "message", "status"?, "reason"?, "code"?}. Fakes return it as the port's error, so the Go code sees a failed call as the Node code did.

func (*RecordedError) Error

func (e *RecordedError) Error() string

Error is the recorded message.

type Topic

type Topic struct {
	Manager string `json:"manager"`
	Router  string `json:"router"`
	Commit  string `json:"commit"`
	Cases   []Case `json:"cases"`
}

Topic is one file of shared cases.

func Load

func Load(t testing.TB, topic string) Topic

Load reads testdata/parity/<topic>.json from the module root.

Jump to

Keyboard shortcuts

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