plugintest

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package plugintest provides an in-process test harness for CVT plugin authors. It lets you exercise your RegistryProvider or EventHandler implementation without forking a subprocess or speaking gRPC.

Use this for unit tests. For end-to-end coverage (handshake, crash recovery, real subprocess), use the framework-level integration test harness in internal/pluginmgr (core team only).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Harness

type Harness struct {
	Registry cvtplugin.RegistryProvider
	Events   cvtplugin.EventHandler
	Config   map[string]string
}

Harness wraps a plugin implementation and exposes the same gRPC-shaped API that core would use. Methods call the implementation directly; no network, no subprocess, no go-plugin machinery.

func New

func New() *Harness

New returns a harness with no plugins. Use WithRegistry / WithEvents to attach implementations.

func (*Harness) FetchSchema

FetchSchema proxies to the attached RegistryProvider.

func (*Harness) OnBreakingChangeDetected

func (h *Harness) OnBreakingChangeDetected(ctx context.Context, req *eventspb.BreakingChangeDetectedRequest) (*eventspb.EventResponse, error)

OnBreakingChangeDetected proxies to the attached EventHandler.

func (*Harness) OnValidationFailed

func (h *Harness) OnValidationFailed(ctx context.Context, req *eventspb.ValidationFailedRequest) (*eventspb.EventResponse, error)

OnValidationFailed proxies to the attached EventHandler.

func (*Harness) RegisterConsumerUsage

RegisterConsumerUsage proxies to the attached RegistryProvider.

func (*Harness) SetConfig

func (h *Harness) SetConfig(ctx context.Context, key, value string) error

SetConfig simulates core delivering a config value. If the plugin implements cvtplugin.ConfigReceiver, it receives the call; otherwise the harness records the value in h.Config for test assertions.

func (*Harness) WithEvents

func (h *Harness) WithEvents(e cvtplugin.EventHandler) *Harness

WithEvents attaches an EventHandler implementation.

func (*Harness) WithRegistry

func (h *Harness) WithRegistry(p cvtplugin.RegistryProvider) *Harness

WithRegistry attaches a RegistryProvider implementation.

Jump to

Keyboard shortcuts

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