Documentation
¶
Overview ¶
Package plugintest provides a test harness for plugin authors to mount their ResourcePluginConfig and assert behavior (CRUD, watch events, health, relationships) without needing gRPC or process spawning.
Index ¶
- type Harness
- func (h *Harness[ClientT]) Close()
- func (h *Harness[ClientT]) Context() context.Context
- func (h *Harness[ClientT]) Create(key string, input resource.CreateInput) *resource.CreateResult
- func (h *Harness[ClientT]) Delete(key string, input resource.DeleteInput) *resource.DeleteResult
- func (h *Harness[ClientT]) ExecuteAction(key, actionID string, input resource.ActionInput) *resource.ActionResult
- func (h *Harness[ClientT]) Get(key string, input resource.GetInput) *resource.GetResult
- func (h *Harness[ClientT]) GetHealth(connID, key string, data json.RawMessage) *resource.ResourceHealth
- func (h *Harness[ClientT]) GetRelationships(key string) []resource.RelationshipDescriptor
- func (h *Harness[ClientT]) List(key string, input resource.ListInput) *resource.ListResult
- func (h *Harness[ClientT]) LoadConnections() []types.Connection
- func (h *Harness[ClientT]) Provider() resource.Provider
- func (h *Harness[ClientT]) Sink() *resourcetest.RecordingSink
- func (h *Harness[ClientT]) StartConnection(id string) types.ConnectionStatus
- func (h *Harness[ClientT]) StopConnection(id string)
- func (h *Harness[ClientT]) Update(key string, input resource.UpdateInput) *resource.UpdateResult
- func (h *Harness[ClientT]) WaitForAdds(count int, timeout time.Duration)
- func (h *Harness[ClientT]) WaitForDeletes(count int, timeout time.Duration)
- func (h *Harness[ClientT]) WaitForUpdates(count int, timeout time.Duration)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Harness ¶
type Harness[ClientT any] struct { // contains filtered or unexported fields }
Harness wraps a resource controller and a recording sink, providing a fluent test API for plugin authors.
func Mount ¶
func Mount[ClientT any](t *testing.T, cfg resource.ResourcePluginConfig[ClientT], opts ...Option[ClientT]) *Harness[ClientT]
Mount builds a resource controller from the given config and returns a Harness ready for testing. The harness starts a background event listener so that watch events are automatically captured by the recording sink.
func (*Harness[ClientT]) Close ¶
func (h *Harness[ClientT]) Close()
Close cancels the harness context and shuts down the controller if it implements io.Closer (the concrete resourceController does).
func (*Harness[ClientT]) Context ¶
Context returns the harness's context, useful for injecting session data.
func (*Harness[ClientT]) Create ¶
func (h *Harness[ClientT]) Create(key string, input resource.CreateInput) *resource.CreateResult
Create delegates to the controller's Create method.
func (*Harness[ClientT]) Delete ¶
func (h *Harness[ClientT]) Delete(key string, input resource.DeleteInput) *resource.DeleteResult
Delete delegates to the controller's Delete method.
func (*Harness[ClientT]) ExecuteAction ¶
func (h *Harness[ClientT]) ExecuteAction(key, actionID string, input resource.ActionInput) *resource.ActionResult
ExecuteAction executes a resource action through the controller.
func (*Harness[ClientT]) GetHealth ¶
func (h *Harness[ClientT]) GetHealth(connID, key string, data json.RawMessage) *resource.ResourceHealth
GetHealth assesses health for a resource from raw data.
func (*Harness[ClientT]) GetRelationships ¶
func (h *Harness[ClientT]) GetRelationships(key string) []resource.RelationshipDescriptor
GetRelationships returns declared relationship descriptors for a resource type.
func (*Harness[ClientT]) LoadConnections ¶
func (h *Harness[ClientT]) LoadConnections() []types.Connection
LoadConnections loads connections from config.
func (*Harness[ClientT]) Provider ¶
Provider returns the underlying resource.Provider for direct access.
func (*Harness[ClientT]) Sink ¶
func (h *Harness[ClientT]) Sink() *resourcetest.RecordingSink
Sink returns the underlying RecordingSink for advanced assertions.
func (*Harness[ClientT]) StartConnection ¶
func (h *Harness[ClientT]) StartConnection(id string) types.ConnectionStatus
StartConnection starts a connection and returns its status.
func (*Harness[ClientT]) StopConnection ¶
StopConnection stops a connection.
func (*Harness[ClientT]) Update ¶
func (h *Harness[ClientT]) Update(key string, input resource.UpdateInput) *resource.UpdateResult
Update delegates to the controller's Update method.
func (*Harness[ClientT]) WaitForAdds ¶
WaitForAdds blocks until at least count add events are recorded.
func (*Harness[ClientT]) WaitForDeletes ¶
WaitForDeletes blocks until at least count delete events are recorded.
type Option ¶
type Option[ClientT any] func(*harnessConfig[ClientT])
Option configures a Harness.
func WithContext ¶
WithContext sets a parent context for the harness.