Documentation
¶
Overview ¶
Package mock provides configurable test doubles for all platform interfaces. Each mock struct uses function pointers for customizable behavior and tracks all method calls for assertion in tests.
Index ¶
- type MockCall
- type MockCapabilityMapper
- func (m *MockCapabilityMapper) CanMap(capabilityType string) bool
- func (m *MockCapabilityMapper) GetCalls() []MockCall
- func (m *MockCapabilityMapper) Map(decl platform.CapabilityDeclaration, pctx *platform.PlatformContext) ([]platform.ResourcePlan, error)
- func (m *MockCapabilityMapper) ValidateConstraints(decl platform.CapabilityDeclaration, constraints []platform.Constraint) []platform.ConstraintViolation
- type MockCredentialBroker
- func (m *MockCredentialBroker) GetCalls() []MockCall
- func (m *MockCredentialBroker) IssueCredential(ctx context.Context, pctx *platform.PlatformContext, ...) (*platform.CredentialRef, error)
- func (m *MockCredentialBroker) ListCredentials(ctx context.Context, pctx *platform.PlatformContext) ([]*platform.CredentialRef, error)
- func (m *MockCredentialBroker) ResolveCredential(ctx context.Context, ref *platform.CredentialRef) (string, error)
- func (m *MockCredentialBroker) RevokeCredential(ctx context.Context, ref *platform.CredentialRef) error
- func (m *MockCredentialBroker) RotateCredential(ctx context.Context, ref *platform.CredentialRef) (*platform.CredentialRef, error)
- type MockLockHandle
- type MockProvider
- func (m *MockProvider) Capabilities() []platform.CapabilityType
- func (m *MockProvider) Close() error
- func (m *MockProvider) CredentialBroker() platform.CredentialBroker
- func (m *MockProvider) GetCalls() []MockCall
- func (m *MockProvider) Healthy(ctx context.Context) error
- func (m *MockProvider) Initialize(ctx context.Context, config map[string]any) error
- func (m *MockProvider) MapCapability(ctx context.Context, decl platform.CapabilityDeclaration, ...) ([]platform.ResourcePlan, error)
- func (m *MockProvider) Name() string
- func (m *MockProvider) ResourceDriver(resourceType string) (platform.ResourceDriver, error)
- func (m *MockProvider) StateStore() platform.StateStore
- func (m *MockProvider) Version() string
- type MockResourceDriver
- func (m *MockResourceDriver) Create(ctx context.Context, name string, properties map[string]any) (*platform.ResourceOutput, error)
- func (m *MockResourceDriver) Delete(ctx context.Context, name string) error
- func (m *MockResourceDriver) Diff(ctx context.Context, name string, desired map[string]any) ([]platform.DiffEntry, error)
- func (m *MockResourceDriver) GetCalls() []MockCall
- func (m *MockResourceDriver) HealthCheck(ctx context.Context, name string) (*platform.HealthStatus, error)
- func (m *MockResourceDriver) Read(ctx context.Context, name string) (*platform.ResourceOutput, error)
- func (m *MockResourceDriver) ResourceType() string
- func (m *MockResourceDriver) Scale(ctx context.Context, name string, scaleParams map[string]any) (*platform.ResourceOutput, error)
- func (m *MockResourceDriver) Update(ctx context.Context, name string, current, desired map[string]any) (*platform.ResourceOutput, error)
- type MockStateStore
- func (m *MockStateStore) AddDependency(ctx context.Context, dep platform.DependencyRef) error
- func (m *MockStateStore) DeleteResource(ctx context.Context, contextPath, resourceName string) error
- func (m *MockStateStore) Dependencies(ctx context.Context, contextPath, resourceName string) ([]platform.DependencyRef, error)
- func (m *MockStateStore) GetCalls() []MockCall
- func (m *MockStateStore) GetPlan(ctx context.Context, planID string) (*platform.Plan, error)
- func (m *MockStateStore) GetResource(ctx context.Context, contextPath, resourceName string) (*platform.ResourceOutput, error)
- func (m *MockStateStore) ListPlans(ctx context.Context, contextPath string, limit int) ([]*platform.Plan, error)
- func (m *MockStateStore) ListResources(ctx context.Context, contextPath string) ([]*platform.ResourceOutput, error)
- func (m *MockStateStore) Lock(ctx context.Context, contextPath string, ttl time.Duration) (platform.LockHandle, error)
- func (m *MockStateStore) SavePlan(ctx context.Context, plan *platform.Plan) error
- func (m *MockStateStore) SaveResource(ctx context.Context, contextPath string, output *platform.ResourceOutput) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockCapabilityMapper ¶
type MockCapabilityMapper struct {
CanMapFn func(capabilityType string) bool
MapFn func(decl platform.CapabilityDeclaration, pctx *platform.PlatformContext) ([]platform.ResourcePlan, error)
ValidateConstraintsFn func(decl platform.CapabilityDeclaration, constraints []platform.Constraint) []platform.ConstraintViolation
Calls []MockCall
// contains filtered or unexported fields
}
MockCapabilityMapper implements platform.CapabilityMapper with configurable function pointers.
func NewMockCapabilityMapper ¶
func NewMockCapabilityMapper() *MockCapabilityMapper
NewMockCapabilityMapper returns a MockCapabilityMapper with sensible defaults.
func (*MockCapabilityMapper) CanMap ¶
func (m *MockCapabilityMapper) CanMap(capabilityType string) bool
func (*MockCapabilityMapper) GetCalls ¶
func (m *MockCapabilityMapper) GetCalls() []MockCall
GetCalls returns a copy of the recorded calls.
func (*MockCapabilityMapper) Map ¶
func (m *MockCapabilityMapper) Map(decl platform.CapabilityDeclaration, pctx *platform.PlatformContext) ([]platform.ResourcePlan, error)
func (*MockCapabilityMapper) ValidateConstraints ¶
func (m *MockCapabilityMapper) ValidateConstraints(decl platform.CapabilityDeclaration, constraints []platform.Constraint) []platform.ConstraintViolation
type MockCredentialBroker ¶
type MockCredentialBroker struct {
IssueCredentialFn func(ctx context.Context, pctx *platform.PlatformContext, request platform.CredentialRequest) (*platform.CredentialRef, error)
RevokeCredentialFn func(ctx context.Context, ref *platform.CredentialRef) error
ResolveCredentialFn func(ctx context.Context, ref *platform.CredentialRef) (string, error)
RotateCredentialFn func(ctx context.Context, ref *platform.CredentialRef) (*platform.CredentialRef, error)
ListCredentialsFn func(ctx context.Context, pctx *platform.PlatformContext) ([]*platform.CredentialRef, error)
Calls []MockCall
// contains filtered or unexported fields
}
MockCredentialBroker implements platform.CredentialBroker with configurable function pointers.
func NewMockCredentialBroker ¶
func NewMockCredentialBroker() *MockCredentialBroker
NewMockCredentialBroker returns a MockCredentialBroker with sensible defaults.
func (*MockCredentialBroker) GetCalls ¶
func (m *MockCredentialBroker) GetCalls() []MockCall
GetCalls returns a copy of the recorded calls.
func (*MockCredentialBroker) IssueCredential ¶
func (m *MockCredentialBroker) IssueCredential(ctx context.Context, pctx *platform.PlatformContext, request platform.CredentialRequest) (*platform.CredentialRef, error)
func (*MockCredentialBroker) ListCredentials ¶
func (m *MockCredentialBroker) ListCredentials(ctx context.Context, pctx *platform.PlatformContext) ([]*platform.CredentialRef, error)
func (*MockCredentialBroker) ResolveCredential ¶
func (m *MockCredentialBroker) ResolveCredential(ctx context.Context, ref *platform.CredentialRef) (string, error)
func (*MockCredentialBroker) RevokeCredential ¶
func (m *MockCredentialBroker) RevokeCredential(ctx context.Context, ref *platform.CredentialRef) error
func (*MockCredentialBroker) RotateCredential ¶
func (m *MockCredentialBroker) RotateCredential(ctx context.Context, ref *platform.CredentialRef) (*platform.CredentialRef, error)
type MockLockHandle ¶
type MockLockHandle struct {
UnlockFn func(ctx context.Context) error
RefreshFn func(ctx context.Context, ttl time.Duration) error
// contains filtered or unexported fields
}
MockLockHandle implements platform.LockHandle for use with MockStateStore.
type MockProvider ¶
type MockProvider struct {
NameFn func() string
VersionFn func() string
InitializeFn func(ctx context.Context, config map[string]any) error
CapabilitiesFn func() []platform.CapabilityType
MapCapabilityFn func(ctx context.Context, decl platform.CapabilityDeclaration, pctx *platform.PlatformContext) ([]platform.ResourcePlan, error)
ResourceDriverFn func(resourceType string) (platform.ResourceDriver, error)
CredentialBrokerFn func() platform.CredentialBroker
StateStoreFn func() platform.StateStore
HealthyFn func(ctx context.Context) error
CloseFn func() error
Calls []MockCall
// contains filtered or unexported fields
}
MockProvider implements platform.Provider with configurable function pointers.
func NewMockProvider ¶
func NewMockProvider() *MockProvider
NewMockProvider returns a MockProvider with sensible defaults.
func (*MockProvider) Capabilities ¶
func (m *MockProvider) Capabilities() []platform.CapabilityType
func (*MockProvider) Close ¶
func (m *MockProvider) Close() error
func (*MockProvider) CredentialBroker ¶
func (m *MockProvider) CredentialBroker() platform.CredentialBroker
func (*MockProvider) GetCalls ¶
func (m *MockProvider) GetCalls() []MockCall
GetCalls returns a copy of the recorded calls.
func (*MockProvider) Initialize ¶
func (*MockProvider) MapCapability ¶
func (m *MockProvider) MapCapability(ctx context.Context, decl platform.CapabilityDeclaration, pctx *platform.PlatformContext) ([]platform.ResourcePlan, error)
func (*MockProvider) Name ¶
func (m *MockProvider) Name() string
func (*MockProvider) ResourceDriver ¶
func (m *MockProvider) ResourceDriver(resourceType string) (platform.ResourceDriver, error)
func (*MockProvider) StateStore ¶
func (m *MockProvider) StateStore() platform.StateStore
func (*MockProvider) Version ¶
func (m *MockProvider) Version() string
type MockResourceDriver ¶
type MockResourceDriver struct {
CreateFn func(ctx context.Context, name string, properties map[string]any) (*platform.ResourceOutput, error)
ReadFn func(ctx context.Context, name string) (*platform.ResourceOutput, error)
UpdateFn func(ctx context.Context, name string, current, desired map[string]any) (*platform.ResourceOutput, error)
DeleteFn func(ctx context.Context, name string) error
HealthCheckFn func(ctx context.Context, name string) (*platform.HealthStatus, error)
ScaleFn func(ctx context.Context, name string, scaleParams map[string]any) (*platform.ResourceOutput, error)
DiffFn func(ctx context.Context, name string, desired map[string]any) ([]platform.DiffEntry, error)
Calls []MockCall
// contains filtered or unexported fields
}
MockResourceDriver implements platform.ResourceDriver with configurable function pointers.
func NewMockResourceDriver ¶
func NewMockResourceDriver(resourceType string) *MockResourceDriver
NewMockResourceDriver returns a MockResourceDriver for the given resource type.
func (*MockResourceDriver) Create ¶
func (m *MockResourceDriver) Create(ctx context.Context, name string, properties map[string]any) (*platform.ResourceOutput, error)
func (*MockResourceDriver) Delete ¶
func (m *MockResourceDriver) Delete(ctx context.Context, name string) error
func (*MockResourceDriver) GetCalls ¶
func (m *MockResourceDriver) GetCalls() []MockCall
GetCalls returns a copy of the recorded calls.
func (*MockResourceDriver) HealthCheck ¶
func (m *MockResourceDriver) HealthCheck(ctx context.Context, name string) (*platform.HealthStatus, error)
func (*MockResourceDriver) Read ¶
func (m *MockResourceDriver) Read(ctx context.Context, name string) (*platform.ResourceOutput, error)
func (*MockResourceDriver) ResourceType ¶
func (m *MockResourceDriver) ResourceType() string
type MockStateStore ¶
type MockStateStore struct {
SaveResourceFn func(ctx context.Context, contextPath string, output *platform.ResourceOutput) error
GetResourceFn func(ctx context.Context, contextPath, resourceName string) (*platform.ResourceOutput, error)
ListResourcesFn func(ctx context.Context, contextPath string) ([]*platform.ResourceOutput, error)
DeleteResourceFn func(ctx context.Context, contextPath, resourceName string) error
SavePlanFn func(ctx context.Context, plan *platform.Plan) error
GetPlanFn func(ctx context.Context, planID string) (*platform.Plan, error)
ListPlansFn func(ctx context.Context, contextPath string, limit int) ([]*platform.Plan, error)
LockFn func(ctx context.Context, contextPath string, ttl time.Duration) (platform.LockHandle, error)
DependenciesFn func(ctx context.Context, contextPath, resourceName string) ([]platform.DependencyRef, error)
AddDependencyFn func(ctx context.Context, dep platform.DependencyRef) error
Calls []MockCall
// contains filtered or unexported fields
}
MockStateStore implements platform.StateStore with configurable function pointers and in-memory storage that works out of the box.
func NewMockStateStore ¶
func NewMockStateStore() *MockStateStore
NewMockStateStore returns a MockStateStore with initialized in-memory maps.
func (*MockStateStore) AddDependency ¶
func (m *MockStateStore) AddDependency(ctx context.Context, dep platform.DependencyRef) error
func (*MockStateStore) DeleteResource ¶
func (m *MockStateStore) DeleteResource(ctx context.Context, contextPath, resourceName string) error
func (*MockStateStore) Dependencies ¶
func (m *MockStateStore) Dependencies(ctx context.Context, contextPath, resourceName string) ([]platform.DependencyRef, error)
func (*MockStateStore) GetCalls ¶
func (m *MockStateStore) GetCalls() []MockCall
GetCalls returns a copy of the recorded calls.
func (*MockStateStore) GetResource ¶
func (m *MockStateStore) GetResource(ctx context.Context, contextPath, resourceName string) (*platform.ResourceOutput, error)
func (*MockStateStore) ListResources ¶
func (m *MockStateStore) ListResources(ctx context.Context, contextPath string) ([]*platform.ResourceOutput, error)
func (*MockStateStore) Lock ¶
func (m *MockStateStore) Lock(ctx context.Context, contextPath string, ttl time.Duration) (platform.LockHandle, error)
func (*MockStateStore) SaveResource ¶
func (m *MockStateStore) SaveResource(ctx context.Context, contextPath string, output *platform.ResourceOutput) error