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 ¶
- type Harness
- func (h *Harness) FetchSchema(ctx context.Context, req *registrypb.FetchSchemaRequest) (*registrypb.FetchSchemaResponse, error)
- func (h *Harness) OnBreakingChangeDetected(ctx context.Context, req *eventspb.BreakingChangeDetectedRequest) (*eventspb.EventResponse, error)
- func (h *Harness) OnValidationFailed(ctx context.Context, req *eventspb.ValidationFailedRequest) (*eventspb.EventResponse, error)
- func (h *Harness) RegisterConsumerUsage(ctx context.Context, req *registrypb.RegisterConsumerUsageRequest) (*registrypb.RegisterConsumerUsageResponse, error)
- func (h *Harness) SetConfig(ctx context.Context, key, value string) error
- func (h *Harness) WithEvents(e cvtplugin.EventHandler) *Harness
- func (h *Harness) WithRegistry(p cvtplugin.RegistryProvider) *Harness
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 ¶
func (h *Harness) FetchSchema(ctx context.Context, req *registrypb.FetchSchemaRequest) (*registrypb.FetchSchemaResponse, error)
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 ¶
func (h *Harness) RegisterConsumerUsage(ctx context.Context, req *registrypb.RegisterConsumerUsageRequest) (*registrypb.RegisterConsumerUsageResponse, error)
RegisterConsumerUsage proxies to the attached RegistryProvider.
func (*Harness) SetConfig ¶
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.