Documentation
¶
Overview ¶
Package testutils provides testing helpers for command testing (command-layer specific).
This package contains testing utilities and shared test errors specifically designed for command tests, providing command-layer specific functionality.
Index ¶
- func CreateConfigManagerWithFieldSelectors(writer io.Writer, ...) *configmanager.ConfigManager
- func CreateDefaultConfigManager() *configmanager.ConfigManager
- func SetupCommandWithOutput() (*cobra.Command, *bytes.Buffer)
- func TestCmdExecuteInCleanDir(t *testing.T, cmdFactory func() *cobra.Command, cmdName string)
- func TestSimpleCommandCreation(t *testing.T, data SimpleCommandTestData)
- func TestSimpleCommandExecution(t *testing.T, data SimpleCommandTestData)
- func TestSimpleCommandHelp(t *testing.T, data SimpleCommandTestData)
- func WriteValidKsailConfig(t *testing.T, dir string)
- type SimpleCommandTestData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateConfigManagerWithFieldSelectors ¶
func CreateConfigManagerWithFieldSelectors( writer io.Writer, fieldSelectors ...configmanager.FieldSelector[v1alpha1.Cluster], ) *configmanager.ConfigManager
CreateConfigManagerWithFieldSelectors creates a config manager with the provided field selectors.
func CreateDefaultConfigManager ¶
func CreateDefaultConfigManager() *configmanager.ConfigManager
CreateDefaultConfigManager creates a standard config manager for cmd tests that passes KSail validation.
func SetupCommandWithOutput ¶
SetupCommandWithOutput creates a standard cobra command with output buffer for cmd tests.
func TestCmdExecuteInCleanDir ¶
TestCmdExecuteInCleanDir executes a command in a temporary directory with no ksail.yaml file and validates that it returns a configuration validation error.
func TestSimpleCommandCreation ¶
func TestSimpleCommandCreation(t *testing.T, data SimpleCommandTestData)
TestSimpleCommandCreation tests command creation with common pattern.
func TestSimpleCommandExecution ¶
func TestSimpleCommandExecution(t *testing.T, data SimpleCommandTestData)
TestSimpleCommandExecution tests command execution with common pattern.
func TestSimpleCommandHelp ¶
func TestSimpleCommandHelp(t *testing.T, data SimpleCommandTestData)
TestSimpleCommandHelp tests command help output with common pattern.
func WriteValidKsailConfig ¶
WriteValidKsailConfig writes a minimal but valid KSail configuration into the provided directory.