mock

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package mock provides a test mock implementation of the infrastructure provider interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Config provider.ProviderConfig
	Logger *slog.Logger
}

Options contains options for creating a mock provider

type Provider

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

Provider implements both the Provider and LoadBalancerProvider interfaces for testing

func NewProvider

func NewProvider(opts Options) *Provider

NewProvider creates a new mock provider

func (*Provider) AssignLeaderNetwork

func (p *Provider) AssignLeaderNetwork(ctx context.Context, providerInstanceID string, ln provider.LeaderNetwork) error

AssignLeaderNetwork is a no-op for mock provider

func (*Provider) CheckSubnetCapacity

func (p *Provider) CheckSubnetCapacity(ctx context.Context, subnetID string) (bool, error)

CheckSubnetCapacity simulates checking subnet capacity (always returns true for mock)

func (*Provider) CreateInstance

CreateInstance simulates creating an instance

func (*Provider) DeleteInstance

func (p *Provider) DeleteInstance(ctx context.Context, instanceID, providerInstanceID string) error

DeleteInstance simulates deleting an instance by provider instance ID

func (*Provider) DeregisterFromLB

func (p *Provider) DeregisterFromLB(ctx context.Context, req provider.DeregisterLBRequest) error

DeregisterFromLB removes an instance from a mock load balancer

func (*Provider) GetInstanceCount

func (p *Provider) GetInstanceCount() int

GetInstanceCount returns the number of instances (for testing)

func (*Provider) GetInstanceStatus

func (p *Provider) GetInstanceStatus(ctx context.Context, instanceID, providerInstanceID string) (*provider.InstanceStatus, error)

GetInstanceStatus returns the status of a mock instance

func (*Provider) Kind

func (p *Provider) Kind() string

func (*Provider) ListInstances

ListInstances returns mock instances with pagination support

func (*Provider) ListLBInstances

func (p *Provider) ListLBInstances(ctx context.Context, req provider.ListLBInstancesRequest) ([]string, error)

ListLBInstances lists all instances currently registered with a mock load balancer

func (*Provider) RegisterWithLB

func (p *Provider) RegisterWithLB(ctx context.Context, req provider.RegisterLBRequest) error

RegisterWithLB registers an instance with a mock load balancer

func (*Provider) ReleaseLeaderNetwork

func (p *Provider) ReleaseLeaderNetwork(ctx context.Context, providerInstanceID string, ln provider.LeaderNetwork) error

ReleaseLeaderNetwork is a no-op for mock provider

func (*Provider) Reset

func (p *Provider) Reset()

Reset clears all instances and resets testing controls

func (*Provider) SetCreateDelay

func (p *Provider) SetCreateDelay(delay time.Duration)

SetCreateDelay sets a delay for instance creation (for testing)

func (*Provider) SetCreateError

func (p *Provider) SetCreateError(err error)

SetCreateError sets an error to return on instance creation (for testing)

func (*Provider) SetDeleteError

func (p *Provider) SetDeleteError(err error)

SetDeleteError sets an error to return on instance deletion (for testing)

func (*Provider) SetStatusError

func (p *Provider) SetStatusError(err error)

SetStatusError sets an error to return on status queries (for testing)

Jump to

Keyboard shortcuts

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