mock

package
v1.27.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package mock provides a mock cluster driver implementation for testing. This package is intended for use in tests only and should not be imported by production code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearErrorConfig

func ClearErrorConfig(profileName string)

ClearErrorConfig clears any configured errors for a profile.

func ProfileExists

func ProfileExists(profileName string) bool

ProfileExists returns true if a cluster profile exists in the global state.

func ResetGlobalState

func ResetGlobalState()

ResetGlobalState resets all cluster state. Should be called in test setup/teardown.

func SetClusterState

func SetClusterState(profileName string, state cluster.State)

SetClusterState allows tests to set up specific cluster states.

func SetErrorConfig

func SetErrorConfig(profileName string, errCfg ErrorConfig)

SetErrorConfig configures the mock driver to return specific errors for a profile.

Types

type ClusterState

type ClusterState struct {
	State             cluster.State
	KubernetesVersion string
	IPAddress         string
	StartCallCount    int
	StopCallCount     int
	DestroyCallCount  int
	StatusCallCount   int
}

ClusterState is a read-only view of cluster state for testing assertions.

func GetState

func GetState(profileName string) *ClusterState

GetState returns the current state of a cluster profile for testing assertions.

type Driver

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

Driver is a mock implementation of cluster.Manager for testing.

func NewDriver

func NewDriver(profileName string) *Driver

NewDriver creates a new mock driver for the given profile.

func (*Driver) Destroy

func (d *Driver) Destroy(ctx context.Context) error

Destroy completely removes the mock cluster.

func (*Driver) Start

func (d *Driver) Start(ctx context.Context, cfg types.ClusterConfig) error

Start starts the mock cluster with the given configuration.

func (*Driver) Status

func (d *Driver) Status(ctx context.Context) (*cluster.Status, error)

Status returns the current status of the mock cluster.

func (*Driver) Stop

func (d *Driver) Stop(ctx context.Context) error

Stop stops the mock cluster.

type ErrorConfig

type ErrorConfig struct {
	StartError   error
	StopError    error
	DestroyError error
	StatusError  error
}

ErrorConfig allows tests to configure the mock driver to return specific errors.

Jump to

Keyboard shortcuts

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