plugintest

package
v0.0.0-...-47ebb28 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: GPL-3.0 Imports: 20 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 plugintest drives a Go plugin's protocol loop over in-memory pipes, as core would.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaseFile

func CaseFile(t testing.TB, name string) []byte

CaseFile is one published file: schema.json, protocol.json or delivery.json.

func Conformance

func Conformance(t *testing.T, p plugin.Package, o Options)

Conformance fails t unless every case passes for every role of p.

func ExpectError

func ExpectError(t *testing.T, r map[string]any, contains string)

ExpectError fails unless r is an error containing contains.

func FieldNames

func FieldNames(describe map[string]any) string

FieldNames is a describe reply's connection field names, comma-separated.

func FrameBytes

func FrameBytes(tag byte, body []byte) []byte

FrameBytes is one frame on the wire.

Types

type Check

type Check struct {
	Plugin string
	Name   string
	// Passed is true for a case that passed or didn't apply.
	Passed bool
	Detail string
	// Skipped says why the case didn't apply; empty when it ran.
	Skipped string
}

Check is one case's outcome for one plugin.

func RunConformance

func RunConformance(t testing.TB, p plugin.Package, o Options) []Check

RunConformance runs every case for every role of p.

type Conversation

type Conversation struct {
	Code chan int
	// Logs holds the `log` and `progress` messages Reply skipped, in order.
	Logs []map[string]any
	// contains filtered or unexported fields
}

Conversation is one plugin process: requests in, replies out.

func Start

func Start(t *testing.T, p plugin.Package, role plugin.Role) *Conversation

Start serves p as role.

func (*Conversation) CloseInput

func (c *Conversation) CloseInput()

CloseInput closes the plugin's stdin.

func (*Conversation) Exec

func (c *Conversation) Exec(sql string) string

Exec runs sql and discards whatever it returns (no_result, or a result set), failing on an error. It returns the first reply's type.

func (*Conversation) Hello

func (c *Conversation) Hello() map[string]any

Hello greets the plugin and returns its hello reply.

func (*Conversation) Message

func (c *Conversation) Message() map[string]any

Message reads the next JSON message, whatever it is.

func (*Conversation) Open

func (c *Conversation) Open(conn map[string]any)

Open opens a session with conn and expects ok.

func (*Conversation) OpenReadOnly

func (c *Conversation) OpenReadOnly(conn map[string]any)

OpenReadOnly opens a session with conn and `read_only: true`, and expects ok.

func (*Conversation) Query

func (c *Conversation) Query(sql string) []arrow.RecordBatch

Query runs sql and returns the result's records, after checking the reply sequence.

func (*Conversation) Records

func (c *Conversation) Records() []arrow.RecordBatch

Records reads one Arrow frame.

func (*Conversation) Reply

func (c *Conversation) Reply() map[string]any

Reply reads one JSON reply, keeping any `log` and `progress` messages before it in Logs.

func (*Conversation) ReplySkippingRecords

func (c *Conversation) ReplySkippingRecords() map[string]any

ReplySkippingRecords is Reply that also discards Arrow frames before the reply, such as a batch already in flight when the plugin was told to cancel.

func (*Conversation) Send

func (c *Conversation) Send(v any)

Send writes one JSON request.

func (*Conversation) SendRaw

func (c *Conversation) SendRaw(b []byte)

SendRaw writes bytes as they are.

func (*Conversation) SendRecord

func (c *Conversation) SendRecord(rec arrow.RecordBatch)

SendRecord writes one Arrow frame.

type Options

type Options struct {
	// Session, when set, runs the session cases (sources).
	Session *Session
}

Options say how to run the suite.

type Protocol

type Protocol struct {
	MinVersion   int
	MaxVersion   int
	Capabilities []string
	ErrorKinds   []string
}

Protocol is the schema's version range, capabilities and error kinds.

type SchemaDoc

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

SchemaDoc is the parsed schema.

func Schema

func Schema(t testing.TB) *SchemaDoc

Schema reads the published schema.

func (*SchemaDoc) CheckResponse

func (s *SchemaDoc) CheckResponse(msg any) error

CheckResponse reports why msg (a decoded JSON message) isn't a message a plugin may send.

func (*SchemaDoc) Protocol

func (s *SchemaDoc) Protocol() Protocol

Protocol is the schema's `x-dre` block.

type Session

type Session struct {
	Connection map[string]any
	Statements map[string]string
}

Session is what the session cases run: a connection that opens, and statements by role (`rows`, `empty`, `no_result`, `error`, `slow`; see docs/protocol.md).

Jump to

Keyboard shortcuts

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