plugintest

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 14 Imported by: ? 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 plugintest supplies a reusable conformance suite for Ext backends. Factories bind Guest() locally or in a dedicated subprocess and must return a fresh owned backend each time. The suite performs real transport calls.

Index

Constants

This section is empty.

Variables

View Source
var (
	FramesContract = plugin.ContractRef{Name: "ext.frames", Version: "v1"}
	FramesHostRef  = plugin.ContractRef{Name: "host.svc", Version: "v1"}
)

Functions

func Descriptor

func Descriptor() plugin.Descriptor

func FramesDescriptor

func FramesDescriptor() plugin.Descriptor

func FramesGuest

func FramesGuest() (*plugin.Guest, error)

FramesGuest is the reference guest of the frames suite.

func Guest

func Guest() (*plugin.Guest, error)

func RegistryCasesPath

func RegistryCasesPath() (string, error)

RegistryCasesPath finds the fixture: it walks up from the working directory to the repository's lib/plugin/testdata/v1, and reports os.ErrNotExist outside the repository (a module fetched on its own).

func Run

func Run(t *testing.T, factory Factory)

func RunFrames

func RunFrames(t *testing.T, factory Factory, opts FramesOptions)

RunFrames runs the frames suite against guests the pure-Go session hosts.

func RunFramesWithHost

func RunFramesWithHost(t *testing.T, factory Factory, openHost OpenFramesHost, opts FramesOptions)

func RunRegistryCases

func RunRegistryCases(t *testing.T, cases RegistryCases, open func(t *testing.T) RegistryHost)

RunRegistryCases runs every case against a fresh host from open.

func RunWithHost

func RunWithHost(t *testing.T, factory Factory, openHost OpenHost)

Types

type Factory

type Factory func(context.Context) (plugin.Backend, error)

type FramesHost

FramesHost is the session surface the frames suite uses.

type FramesOptions

type FramesOptions struct {
	// Concurrent is true for a guest that can wait for the host's answer to a
	// request and still serve what arrives, so it can have several requests
	// outstanding at once and call its host between forward calls (a thread, or an
	// event loop). A guest without it, such as a WebAssembly command or a
	// single-threaded one, answers those operations with the public error
	// "unsupported".
	Concurrent bool
}

FramesOptions says what the guest under test can do.

type Host

type Host interface {
	Call(context.Context, plugin.ContractRef, string, json.RawMessage) (json.RawMessage, error)
	State() plugin.State
	Close(context.Context) error
	Abort() error
}

Host is the common session surface exercised by backend conformance. A language binding may run the same suite without wrapping a Go Session.

type RegistryCase

type RegistryCase struct {
	Name        string         `json:"name"`
	ReverseDeny []string       `json:"reverseDeny"`
	ForwardDeny []string       `json:"forwardDeny"`
	Steps       []RegistryStep `json:"steps"`
}

RegistryCase is one case: the guests whose reverse or forward authorize denies, and the steps.

type RegistryCases

type RegistryCases struct {
	Guest struct {
		Reverse struct {
			Name       string   `json:"name"`
			Version    string   `json:"version"`
			Operations []string `json:"operations"`
		} `json:"reverse"`
		FailError plugin.RemoteError `json:"failError"`
	} `json:"guest"`
	// Guests maps a guest's name to the contract it serves (version v1).
	Guests map[string]string `json:"guests"`
	Edges  []RegistryEdge    `json:"edges"`
	Cases  []RegistryCase    `json:"cases"`
}

RegistryCases is the shared guest registry fixture, lib/plugin/testdata/v1/registry-cases.json: the relay guest, the guests a case opens, the edges it declares and the cases. Its "about" fields say what a host runs.

func ReadRegistryCases

func ReadRegistryCases(path string) (RegistryCases, error)

ReadRegistryCases reads the fixture at path.

func (RegistryCases) Contract

func (c RegistryCases) Contract(name string) plugin.ContractRef

Contract is the contract the named guest serves.

func (RegistryCases) RelayDescriptor

func (c RegistryCases) RelayDescriptor(name string) plugin.Descriptor

RelayDescriptor is the descriptor of the named relay guest.

func (RegistryCases) RelayGuest

func (c RegistryCases) RelayGuest(name string) (*plugin.Guest, error)

RelayGuest is the named relay guest, which the fixture's guest.about describes.

type RegistryEdge

type RegistryEdge struct {
	From RegistryEdgeEnd `json:"from"`
	To   RegistryEdgeEnd `json:"to"`
}

RegistryEdge routes the reverse operation From to the forward operation To.

type RegistryEdgeEnd

type RegistryEdgeEnd struct {
	Name      string `json:"name"`
	Version   string `json:"version"`
	Operation string `json:"operation"`
}

RegistryEdgeEnd is one end of an edge.

func (RegistryEdgeEnd) Ref

Ref is the end's contract.

type RegistryHost

type RegistryHost interface {
	// Open opens, attaches and registers the named guest. denyForward makes its
	// forward authorize deny, denyReverse its reverse authorize.
	Open(name string, contract plugin.ContractRef, denyForward, denyReverse bool) error
	Route(RegistryEdge) error
	Unregister(contract plugin.ContractRef) error
	Call(ctx context.Context, name string, contract plugin.ContractRef, operation string, payload json.RawMessage) (json.RawMessage, error)
	// Close closes every host and frees the registry.
	Close()
}

RegistryHost is what RunRegistryCases drives: the hosts of one case, each guest attached to one registry as a source.

type RegistryStep

type RegistryStep struct {
	Call        string          `json:"call"`
	Operation   string          `json:"operation"`
	Payload     json.RawMessage `json:"payload"`
	TimeoutMs   int             `json:"timeoutMs"`
	Result      json.RawMessage `json:"result"`
	ResultError []string        `json:"resultError"`
	Unregister  string          `json:"unregister"`
}

RegistryStep calls a guest's operation, or unregisters a guest's contract.

Directories

Path Synopsis
Package enginetest holds the differential checks that hold an engine of the shared C implementation against the pure-Go engine, which is the oracle: the same documents, requests, schemas and endpoints are judged by both, and the answers must agree.
Package enginetest holds the differential checks that hold an engine of the shared C implementation against the pure-Go engine, which is the oracle: the same documents, requests, schemas and endpoints are judged by both, and the answers must agree.

Jump to

Keyboard shortcuts

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