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 ¶
- Variables
- func Descriptor() plugin.Descriptor
- func FramesDescriptor() plugin.Descriptor
- func FramesGuest() (*plugin.Guest, error)
- func Guest() (*plugin.Guest, error)
- func RegistryCasesPath() (string, error)
- func Run(t *testing.T, factory Factory)
- func RunFrames(t *testing.T, factory Factory, opts FramesOptions)
- func RunFramesWithHost(t *testing.T, factory Factory, openHost OpenFramesHost, opts FramesOptions)
- func RunRegistryCases(t *testing.T, cases RegistryCases, open func(t *testing.T) RegistryHost)
- func RunWithHost(t *testing.T, factory Factory, openHost OpenHost)
- type Factory
- type FramesHost
- type FramesOptions
- type Host
- type OpenFramesHost
- type OpenHost
- type RegistryCase
- type RegistryCases
- type RegistryEdge
- type RegistryEdgeEnd
- type RegistryHost
- type RegistryStep
Constants ¶
This section is empty.
Variables ¶
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 ¶
FramesGuest is the reference guest of the frames suite.
func RegistryCasesPath ¶
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 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.
Types ¶
type FramesHost ¶
type FramesHost interface {
Call(context.Context, plugin.ContractRef, string, json.RawMessage) (json.RawMessage, error)
CallProgress(context.Context, plugin.ContractRef, string, json.RawMessage, func(plugin.Progress), ...plugin.CallOptions) (json.RawMessage, error)
State() plugin.State
Abort() error
}
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 OpenFramesHost ¶
type OpenFramesHost func(context.Context, plugin.Descriptor, plugin.Options) (FramesHost, error)
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 ¶
func (e RegistryEdgeEnd) Ref() plugin.ContractRef
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. |