Documentation
¶
Overview ¶
Package testutils provides shared helpers for cluster command tests.
Index ¶
- func CreateConfigManager(t *testing.T, writer io.Writer) *ksailconfigmanager.ConfigManager
- func NewCommand(t *testing.T) (*cobra.Command, *bytes.Buffer)
- func RunValidationErrorTest(t *testing.T, commandFactory func() *cobra.Command, ...)
- func SetupValidWorkingDir(t *testing.T) func()
- type RecordingTimer
- type StubFactory
- type StubProvisioner
- func (p *StubProvisioner) Create(_ context.Context, name string) error
- func (p *StubProvisioner) Delete(_ context.Context, name string) error
- func (p *StubProvisioner) Exists(context.Context, string) (bool, error)
- func (p *StubProvisioner) List(context.Context) ([]string, error)
- func (p *StubProvisioner) Start(_ context.Context, name string) error
- func (p *StubProvisioner) Stop(_ context.Context, name string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateConfigManager ¶
func CreateConfigManager(t *testing.T, writer io.Writer) *ksailconfigmanager.ConfigManager
CreateConfigManager creates a config manager for testing with a valid ksail config.
func NewCommand ¶
NewCommand creates a test command with output buffers.
func RunValidationErrorTest ¶
func RunValidationErrorTest( t *testing.T, commandFactory func() *cobra.Command, expectedSubstrings ...string, )
RunValidationErrorTest executes the provided command factory in an empty directory and validates error output.
func SetupValidWorkingDir ¶
SetupValidWorkingDir creates a valid KSail configuration in a temporary directory and switches to it. The returned cleanup function restores the original working directory.
Types ¶
type RecordingTimer ¶
RecordingTimer is a test double for timer.Timer that records method calls.
func (*RecordingTimer) GetTiming ¶
func (r *RecordingTimer) GetTiming() (time.Duration, time.Duration)
GetTiming implements timer.Timer.
func (*RecordingTimer) NewStage ¶
func (r *RecordingTimer) NewStage()
NewStage implements timer.Timer.
type StubFactory ¶
type StubFactory struct {
Provisioner clusterprovisioner.ClusterProvisioner
DistributionConfig any
Err error
CallCount int
}
StubFactory is a test double for clusterprovisioner.Factory.
func (*StubFactory) Create ¶
func (s *StubFactory) Create( _ context.Context, _ *v1alpha1.Cluster, ) (clusterprovisioner.ClusterProvisioner, any, error)
Create implements clusterprovisioner.Factory.
type StubProvisioner ¶
type StubProvisioner struct {
CreateErr error
CreateCalls int
DeleteErr error
DeleteCalls int
StartErr error
StartCalls int
StopErr error
StopCalls int
ReceivedNames []string
}
StubProvisioner is a test double for clusterprovisioner.ClusterProvisioner.
func (*StubProvisioner) Create ¶
func (p *StubProvisioner) Create(_ context.Context, name string) error
Create implements clusterprovisioner.ClusterProvisioner.
func (*StubProvisioner) Delete ¶
func (p *StubProvisioner) Delete(_ context.Context, name string) error
Delete implements clusterprovisioner.ClusterProvisioner.
func (*StubProvisioner) List ¶
func (p *StubProvisioner) List(context.Context) ([]string, error)
List implements clusterprovisioner.ClusterProvisioner.