testutils

package
v1.12.5 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

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

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

func SetupCommandWithOutput() (*cobra.Command, *bytes.Buffer)

SetupCommandWithOutput creates a standard cobra command with output buffer for cmd tests.

func TestCmdExecuteInCleanDir

func TestCmdExecuteInCleanDir(t *testing.T, cmdFactory func() *cobra.Command, cmdName string)

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

func WriteValidKsailConfig(t *testing.T, dir string)

WriteValidKsailConfig writes a minimal but valid KSail configuration into the provided directory.

Types

type SimpleCommandTestData

type SimpleCommandTestData struct {
	CommandName   string
	NewCommand    func() *cobra.Command
	ExpectedUse   string
	ExpectedShort string
}

SimpleCommandTestData holds test data for simple command testing.

Jump to

Keyboard shortcuts

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