testutils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package testutils provides modern testing utilities following 2025 testing standards for the Nephoran Intent Operator with comprehensive test patterns and fixtures.

Package testutils provides configuration and setup for 2025 testing standards

Index

Constants

This section is empty.

Variables

View Source
var (
	NetworkIntentFixture = &NetworkIntentFixtures{}

	E2NodeSetFixture = &E2NodeSetFixtures{}

	ConfigMapFixture = &ConfigMapFixtures{}
)

Functions

func CreateTestContext

func CreateTestContext(timeout time.Duration) (context.Context, context.CancelFunc)

func CreateTestNamespace

func CreateTestNamespace(ctx context.Context, client ctrlclient.Client, namespace string) error

func DeleteTestNamespace

func DeleteTestNamespace(ctx context.Context, client ctrlclient.Client, namespace string) error

func GetAllConfigMaps

func GetAllConfigMaps(ctx context.Context, client ctrlclient.Client, namespace string) ([]corev1.ConfigMap, error)

func GetAllDeployments

func GetAllDeployments(ctx context.Context, client ctrlclient.Client, namespace string) ([]appsv1.Deployment, error)

func GetAllPods

func GetAllPods(ctx context.Context, client ctrlclient.Client, namespace string) ([]corev1.Pod, error)

func GetAllSecrets

func GetAllSecrets(ctx context.Context, client ctrlclient.Client, namespace string) ([]corev1.Secret, error)

func GetAllServices

func GetAllServices(ctx context.Context, client ctrlclient.Client, namespace string) ([]corev1.Service, error)

func GetClientset

func GetClientset() *kubernetes.Clientset

func GetK8sClient

func GetK8sClient() ctrlclient.Client

func GetRestConfig

func GetRestConfig() *rest.Config

func GetTestContext

func GetTestContext() context.Context

func GetTestNamespace

func GetTestNamespace() string

func RunSecurityTestSuite

func RunSecurityTestSuite(t *testing.T, suite TestSuite, helper *SecurityTestHelper)

func RunTableTests

func RunTableTests[T any, R any](
	t *testing.T,
	testFunc func(context.Context, T) (R, error),
	testCases []TableTestCase[T, R],
)

RunTableTests executes table-driven tests with enhanced error handling

func SetupTestEnvironment

func SetupTestEnvironment() error

func TeardownTestEnvironment

func TeardownTestEnvironment() error

func WaitForCondition

func WaitForCondition(ctx context.Context, condition func() bool, timeout time.Duration) bool

func WaitForDeploymentReady

func WaitForDeploymentReady(ctx context.Context, client ctrlclient.Client, namespace, name string, timeout time.Duration) error

Types

type AssertionHelper

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

AssertionHelper provides enhanced assertions following 2025 testing standards

func NewAssertionHelper

func NewAssertionHelper(t *testing.T) *AssertionHelper

NewAssertionHelper creates a new assertion helper

func (*AssertionHelper) AssertHTTPStatusCode

func (a *AssertionHelper) AssertHTTPStatusCode(expected, actual int, url string, msgAndArgs ...interface{})

AssertHTTPStatusCode asserts HTTP response status with context

func (*AssertionHelper) RequireEqual

func (a *AssertionHelper) RequireEqual(expected, actual interface{}, msgAndArgs ...interface{})

RequireEqual asserts equality with type-safe comparison

func (*AssertionHelper) RequireEventuallyTrue

func (a *AssertionHelper) RequireEventuallyTrue(condition func() bool, timeout time.Duration, msgAndArgs ...interface{})

RequireEventuallyTrue implements eventual consistency testing

func (*AssertionHelper) RequireJSONEqual

func (a *AssertionHelper) RequireJSONEqual(expected, actual json.RawMessage, msgAndArgs ...interface{})

RequireJSONEqual asserts JSON equality with detailed diff

func (*AssertionHelper) RequireNoError

func (a *AssertionHelper) RequireNoError(err error, msgAndArgs ...interface{})

RequireNoError asserts that error is nil with enhanced error reporting

type BenchmarkHelper

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

BenchmarkHelper provides utilities for performance testing

func NewBenchmarkHelper

func NewBenchmarkHelper(b *testing.B) *BenchmarkHelper

NewBenchmarkHelper creates a new benchmark helper

func (*BenchmarkHelper) MeasureAsyncOperation

func (bh *BenchmarkHelper) MeasureAsyncOperation(operation func() <-chan struct{})

MeasureAsyncOperation measures async operation performance

func (*BenchmarkHelper) MeasureOperation

func (bh *BenchmarkHelper) MeasureOperation(operation func())

MeasureOperation measures operation performance with memory tracking

type BenchmarkResult

type BenchmarkResult struct {
	Name string

	Duration time.Duration

	Success bool

	Error error
}

func RunBenchmark

func RunBenchmark(name string, testFunc func() error) BenchmarkResult

type ConcurrentTestRunner

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

func NewConcurrentTestRunner

func NewConcurrentTestRunner(workers int) *ConcurrentTestRunner

func (*ConcurrentTestRunner) AddOperation

func (c *ConcurrentTestRunner) AddOperation(op func() error)

func (*ConcurrentTestRunner) Run

func (c *ConcurrentTestRunner) Run() []error

type ConfigMapFixtures

type ConfigMapFixtures struct{}

func (*ConfigMapFixtures) CreateE2NodeConfigMap

func (cmf *ConfigMapFixtures) CreateE2NodeConfigMap(name, namespace string, nodeIndex int) *corev1.ConfigMap

type E2NodeSetFixtures

type E2NodeSetFixtures struct{}

func (*E2NodeSetFixtures) CreateBasicE2NodeSet

func (enf *E2NodeSetFixtures) CreateBasicE2NodeSet(name, namespace string, replicas int32) *nephoranv1.E2NodeSet

func (*E2NodeSetFixtures) CreateReadyE2NodeSet

func (enf *E2NodeSetFixtures) CreateReadyE2NodeSet(name, namespace string, replicas int32) *nephoranv1.E2NodeSet

func (*E2NodeSetFixtures) CreateScalingE2NodeSet

func (enf *E2NodeSetFixtures) CreateScalingE2NodeSet(name, namespace string, replicas int32, currentNodes int32) *nephoranv1.E2NodeSet

type FixtureManager

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

FixtureManager handles test data and fixtures following 2025 patterns

func NewFixtureManager

func NewFixtureManager() *FixtureManager

NewFixtureManager creates a new fixture manager

func (*FixtureManager) CreateLLMResponseFixture

func (fm *FixtureManager) CreateLLMResponseFixture(intentType string, confidence float64) *LLMResponse

CreateLLMResponseFixture creates a standardized LLM response fixture

func (*FixtureManager) CreateNetworkIntentFixture

func (fm *FixtureManager) CreateNetworkIntentFixture(name, namespace, intentType string) map[string]interface{}

CreateNetworkIntentFixture creates a NetworkIntent test fixture

func (*FixtureManager) LoadFixture

func (fm *FixtureManager) LoadFixture(name string, target interface{}) error

LoadFixture loads a fixture by name with type safety

func (*FixtureManager) RegisterFixture

func (fm *FixtureManager) RegisterFixture(name string, fixture interface{})

RegisterFixture registers a fixture with the manager

type LLMResponse

type LLMResponse struct {
	IntentType string `json:"intent_type"`

	Confidence float64 `json:"confidence"`

	Parameters json.RawMessage `json:"parameters"`

	Manifests json.RawMessage `json:"manifests"`

	ProcessingTime int64 `json:"processing_time"`

	TokensUsed int `json:"tokens_used"`

	Model string `json:"model"`
}

func CreateMockLLMResponse

func CreateMockLLMResponse(intentType string, confidence float64) *LLMResponse

type MemoryTracker

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

func NewMemoryTracker

func NewMemoryTracker() *MemoryTracker

func (*MemoryTracker) Start

func (m *MemoryTracker) Start()

func (*MemoryTracker) Stop

func (m *MemoryTracker) Stop() uint64

type MockDependencies

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

func NewMockDependencies

func NewMockDependencies() *MockDependencies

func (*MockDependencies) GetCallCount

func (m *MockDependencies) GetCallCount(operation string) int

func (*MockDependencies) GetEventRecorder

func (m *MockDependencies) GetEventRecorder() record.EventRecorder

func (*MockDependencies) GetGitClient

func (m *MockDependencies) GetGitClient() git.ClientInterface

func (*MockDependencies) GetHTTPClient

func (m *MockDependencies) GetHTTPClient() *http.Client

func (*MockDependencies) GetLLMClient

func (m *MockDependencies) GetLLMClient() shared.ClientInterface

func (*MockDependencies) GetMetricsCollector

func (m *MockDependencies) GetMetricsCollector() monitoring.MetricsCollector

func (*MockDependencies) GetPackageGenerator

func (m *MockDependencies) GetPackageGenerator() *nephio.PackageGenerator

func (*MockDependencies) GetTelecomKnowledgeBase

func (m *MockDependencies) GetTelecomKnowledgeBase() *telecom.TelecomKnowledgeBase

func (*MockDependencies) SetDelay

func (m *MockDependencies) SetDelay(operation string, delay time.Duration)

func (*MockDependencies) SetError

func (m *MockDependencies) SetError(operation string, err error)

type MockGitClient

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

func NewMockGitClient

func NewMockGitClient() *MockGitClient

func (*MockGitClient) Clone

func (m *MockGitClient) Clone(ctx context.Context, url, branch, path string) error

func (*MockGitClient) CommitAndPush

func (m *MockGitClient) CommitAndPush(files map[string]string, message string) (string, error)

func (*MockGitClient) CommitAndPushChanges

func (m *MockGitClient) CommitAndPushChanges(message string) error

func (*MockGitClient) CommitFiles

func (m *MockGitClient) CommitFiles(files []string, msg string) error

func (*MockGitClient) CreateBranch

func (m *MockGitClient) CreateBranch(name string) error

func (*MockGitClient) GetCurrentBranch

func (m *MockGitClient) GetCurrentBranch() (string, error)

func (*MockGitClient) GetFileContent

func (m *MockGitClient) GetFileContent(path string) ([]byte, error)

func (*MockGitClient) InitRepo

func (m *MockGitClient) InitRepo() error

func (*MockGitClient) ListBranches

func (m *MockGitClient) ListBranches() ([]string, error)

func (*MockGitClient) Pull

func (m *MockGitClient) Pull(ctx context.Context, repoPath string) error

func (*MockGitClient) RemoveDirectory

func (m *MockGitClient) RemoveDirectory(path, commitMessage string) error

func (*MockGitClient) SwitchBranch

func (m *MockGitClient) SwitchBranch(name string) error

type MockHTTPClient

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

func NewMockHTTPClient

func NewMockHTTPClient() *MockHTTPClient

type MockLLMClient

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

MockLLMClient implements shared.ClientInterface for testing.

func NewMockLLMClient

func NewMockLLMClient() *MockLLMClient

func (*MockLLMClient) Close

func (m *MockLLMClient) Close() error

func (*MockLLMClient) EstimateTokens

func (m *MockLLMClient) EstimateTokens(text string) int

func (*MockLLMClient) GetEndpoint

func (m *MockLLMClient) GetEndpoint() string

GetEndpoint implements shared.ClientInterface.GetEndpoint

func (*MockLLMClient) GetMaxTokens

func (m *MockLLMClient) GetMaxTokens(modelName string) int

func (*MockLLMClient) GetModelCapabilities

func (m *MockLLMClient) GetModelCapabilities() shared.ModelCapabilities

GetModelCapabilities implements shared.ClientInterface.GetModelCapabilities

func (*MockLLMClient) GetModelCapabilitiesLegacy

func (m *MockLLMClient) GetModelCapabilitiesLegacy(modelName string) (*shared.ModelCapabilities, error)

Legacy method for backward compatibility - returns model capabilities with error

func (*MockLLMClient) GetStatus

func (m *MockLLMClient) GetStatus() shared.ClientStatus

func (*MockLLMClient) GetSupportedModels

func (m *MockLLMClient) GetSupportedModels() []string

func (*MockLLMClient) HealthCheck

func (m *MockLLMClient) HealthCheck(ctx context.Context) error

func (*MockLLMClient) ProcessIntent

func (m *MockLLMClient) ProcessIntent(ctx context.Context, prompt string) (string, error)

func (*MockLLMClient) ProcessIntentStream

func (m *MockLLMClient) ProcessIntentStream(ctx context.Context, prompt string, chunks chan<- *shared.StreamingChunk) error

func (*MockLLMClient) ProcessRequest

func (m *MockLLMClient) ProcessRequest(ctx context.Context, request *shared.LLMRequest) (*shared.LLMResponse, error)

ProcessRequest implements shared.ClientInterface.ProcessRequest

func (*MockLLMClient) ProcessStreamingRequest

func (m *MockLLMClient) ProcessStreamingRequest(ctx context.Context, request *shared.LLMRequest) (<-chan *shared.StreamingChunk, error)

ProcessStreamingRequest implements shared.ClientInterface.ProcessStreamingRequest

func (*MockLLMClient) SetError

func (m *MockLLMClient) SetError(operation string, err error)

func (*MockLLMClient) SetResponse

func (m *MockLLMClient) SetResponse(operation string, response *LLMResponse)

func (*MockLLMClient) ValidateModel

func (m *MockLLMClient) ValidateModel(modelName string) error

type MockMetricsCollector

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

func NewMockMetricsCollector

func NewMockMetricsCollector() *MockMetricsCollector

func (*MockMetricsCollector) CollectMetrics

func (m *MockMetricsCollector) CollectMetrics(ctx context.Context, source string) (*monitoring.MetricsData, error)

func (*MockMetricsCollector) GetCounter

func (m *MockMetricsCollector) GetCounter(name string) interface{}

GetCounter returns a counter interface

func (*MockMetricsCollector) GetGauge

func (m *MockMetricsCollector) GetGauge(name string) interface{}

GetGauge returns a gauge interface

func (*MockMetricsCollector) GetHistogram

func (m *MockMetricsCollector) GetHistogram(name string) interface{}

GetHistogram returns a histogram interface

func (*MockMetricsCollector) GetLabels

func (m *MockMetricsCollector) GetLabels(name string) map[string]string

func (*MockMetricsCollector) GetMetric

func (m *MockMetricsCollector) GetMetric(name string) float64

func (*MockMetricsCollector) RecordCNFDeployment

func (m *MockMetricsCollector) RecordCNFDeployment(functionName string, duration time.Duration)

RecordCNFDeployment records CNF deployment metrics

func (*MockMetricsCollector) RecordE2NodeSetOperation

func (m *MockMetricsCollector) RecordE2NodeSetOperation(operation string, duration time.Duration)

func (*MockMetricsCollector) RecordE2NodeSetScaling

func (m *MockMetricsCollector) RecordE2NodeSetScaling(name, namespace, direction string)

func (*MockMetricsCollector) RecordGitOpsOperation

func (m *MockMetricsCollector) RecordGitOpsOperation(operation string, duration time.Duration, success bool)

func (*MockMetricsCollector) RecordHTTPRequest

func (m *MockMetricsCollector) RecordHTTPRequest(method, endpoint, status string, duration time.Duration)

RecordHTTPRequest records HTTP request metrics

func (*MockMetricsCollector) RecordKubernetesAPILatency

func (m *MockMetricsCollector) RecordKubernetesAPILatency(latency time.Duration)

func (*MockMetricsCollector) RecordLLMRequest

func (m *MockMetricsCollector) RecordLLMRequest(model, status string, duration time.Duration, tokensUsed int)

func (*MockMetricsCollector) RecordLLMRequestError

func (m *MockMetricsCollector) RecordLLMRequestError(model, errorType string)

RecordLLMRequestError records LLM request error metrics

func (*MockMetricsCollector) RecordMetric

func (m *MockMetricsCollector) RecordMetric(name string, value float64, labels map[string]string)

func (*MockMetricsCollector) RecordNetworkIntentProcessed

func (m *MockMetricsCollector) RecordNetworkIntentProcessed(intentType, status string, duration time.Duration)

func (*MockMetricsCollector) RecordNetworkIntentRetry

func (m *MockMetricsCollector) RecordNetworkIntentRetry(name, namespace, reason string)

func (*MockMetricsCollector) RecordORANInterfaceError

func (m *MockMetricsCollector) RecordORANInterfaceError(interfaceType, operation, errorType string)

func (*MockMetricsCollector) RecordORANInterfaceRequest

func (m *MockMetricsCollector) RecordORANInterfaceRequest(interfaceType, operation, status string, duration time.Duration)

func (*MockMetricsCollector) RecordRAGOperation

func (m *MockMetricsCollector) RecordRAGOperation(duration time.Duration, cacheHit bool)

func (*MockMetricsCollector) RecordSSEStream

func (m *MockMetricsCollector) RecordSSEStream(endpoint string, connected bool)

RecordSSEStream records server-sent events stream metrics

func (*MockMetricsCollector) RegisterMetrics

func (m *MockMetricsCollector) RegisterMetrics(registry interface{}) error

func (*MockMetricsCollector) Start

func (m *MockMetricsCollector) Start(ctx context.Context) error

func (*MockMetricsCollector) Stop

func (m *MockMetricsCollector) Stop() error

func (*MockMetricsCollector) UpdateControllerHealth

func (m *MockMetricsCollector) UpdateControllerHealth(controllerName, component string, healthy bool)

func (*MockMetricsCollector) UpdateE2NodeSetReplicas

func (m *MockMetricsCollector) UpdateE2NodeSetReplicas(name, namespace, status string, count int)

func (*MockMetricsCollector) UpdateGitOpsSyncStatus

func (m *MockMetricsCollector) UpdateGitOpsSyncStatus(repository, branch string, inSync bool)

func (*MockMetricsCollector) UpdateNetworkIntentStatus

func (m *MockMetricsCollector) UpdateNetworkIntentStatus(name, namespace, intentType, status string)

func (*MockMetricsCollector) UpdateORANConnectionStatus

func (m *MockMetricsCollector) UpdateORANConnectionStatus(interfaceType, endpoint string, connected bool)

func (*MockMetricsCollector) UpdateORANPolicyInstances

func (m *MockMetricsCollector) UpdateORANPolicyInstances(policyType, status string, count int)

func (*MockMetricsCollector) UpdateRAGDocumentsIndexed

func (m *MockMetricsCollector) UpdateRAGDocumentsIndexed(count int)

func (*MockMetricsCollector) UpdateResourceUtilization

func (m *MockMetricsCollector) UpdateResourceUtilization(resourceType, unit string, value float64)

func (*MockMetricsCollector) UpdateWorkerQueueMetrics

func (m *MockMetricsCollector) UpdateWorkerQueueMetrics(queueName string, depth int, latency time.Duration)

type MockPackageGenerator

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

func NewMockPackageGenerator

func NewMockPackageGenerator() *MockPackageGenerator

func (*MockPackageGenerator) GeneratePackage

func (m *MockPackageGenerator) GeneratePackage(intentType string, parameters map[string]interface{}) (map[string]string, error)

func (*MockPackageGenerator) SetError

func (m *MockPackageGenerator) SetError(operation string, err error)

type NetworkIntentFixtures

type NetworkIntentFixtures struct{}

func (*NetworkIntentFixtures) CreateBasicNetworkIntent

func (nif *NetworkIntentFixtures) CreateBasicNetworkIntent(name, namespace string) *nephoranv1.NetworkIntent

func (*NetworkIntentFixtures) CreateDeployedNetworkIntent

func (nif *NetworkIntentFixtures) CreateDeployedNetworkIntent(name, namespace string) *nephoranv1.NetworkIntent

func (*NetworkIntentFixtures) CreateProcessingNetworkIntent

func (nif *NetworkIntentFixtures) CreateProcessingNetworkIntent(name, namespace string) *nephoranv1.NetworkIntent

type PerformanceTracker

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

func NewPerformanceTracker

func NewPerformanceTracker() *PerformanceTracker

func (*PerformanceTracker) GetAllDurations

func (p *PerformanceTracker) GetAllDurations() map[string]time.Duration

func (*PerformanceTracker) GetDuration

func (p *PerformanceTracker) GetDuration(operation string) time.Duration

func (*PerformanceTracker) Start

func (p *PerformanceTracker) Start(operation string)

func (*PerformanceTracker) Stop

func (p *PerformanceTracker) Stop(operation string) time.Duration

type SecurityTestHelper

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

func NewSecurityTestHelper

func NewSecurityTestHelper(client ctrlclient.Client, clientset *kubernetes.Clientset, namespace string) *SecurityTestHelper

func (*SecurityTestHelper) CheckImageSecurity

func (h *SecurityTestHelper) CheckImageSecurity(container *corev1.Container) []string

func (*SecurityTestHelper) GetSecurityViolations

func (h *SecurityTestHelper) GetSecurityViolations(ctx context.Context) (map[string][]string, error)

func (*SecurityTestHelper) ValidateContainerSecurityContext

func (h *SecurityTestHelper) ValidateContainerSecurityContext(container *corev1.Container) []string

func (*SecurityTestHelper) ValidatePodSecurityContext

func (h *SecurityTestHelper) ValidatePodSecurityContext(pod *corev1.Pod) []string

func (*SecurityTestHelper) ValidateResourceLimits

func (h *SecurityTestHelper) ValidateResourceLimits(container *corev1.Container) []string

type TableTestCase

type TableTestCase[T any, R any] struct {
	Name        string
	Input       T
	Expected    R
	ShouldError bool
	ErrorType   error
	Setup       func(*TestContext) error
	Teardown    func(*TestContext)
	Timeout     time.Duration
}

TableTestCase represents a table-driven test case following 2025 patterns

type TestCase

type TestCase struct {
	Name string

	Description string

	TestFunc func(*testing.T, *SecurityTestHelper) error
}

type TestConfig

type TestConfig struct {
	// Timeouts
	DefaultTimeout     time.Duration
	IntegrationTimeout time.Duration
	E2ETimeout         time.Duration

	// Parallelism
	MaxParallelTests    int
	EnableParallelTests bool

	// Test Environment
	TestNamespacePrefix string
	CleanupAfterTests   bool
	PreserveFailures    bool

	// Performance Testing
	BenchmarkIterations   int
	MemoryTrackingEnabled bool

	// Coverage
	CoverageThreshold  float64
	CoverageReportPath string

	// Debugging
	VerboseLogging bool
	DebugMode      bool

	// CI/CD Integration
	IsCI                bool
	GenerateJUnitReport bool
	JUnitReportPath     string
}

TestConfig holds configuration for modern testing patterns

func DefaultTestConfig

func DefaultTestConfig() *TestConfig

DefaultTestConfig returns the default configuration for testing

func LoadTestConfigFromEnv

func LoadTestConfigFromEnv() *TestConfig

LoadTestConfigFromEnv loads configuration from environment variables

func (*TestConfig) GetCoverageThreshold

func (c *TestConfig) GetCoverageThreshold() float64

GetCoverageThreshold returns the required code coverage threshold

func (*TestConfig) GetMaxParallelism

func (c *TestConfig) GetMaxParallelism() int

GetMaxParallelism returns the maximum number of parallel tests

func (*TestConfig) GetTestTimeout

func (c *TestConfig) GetTestTimeout(testType string) time.Duration

GetTestTimeout returns the appropriate timeout for the test type

func (*TestConfig) ShouldPreserveTestResources

func (c *TestConfig) ShouldPreserveTestResources() bool

ShouldPreserveTestResources determines if test resources should be preserved on failure

func (*TestConfig) ShouldRunInParallel

func (c *TestConfig) ShouldRunInParallel() bool

ShouldRunInParallel determines if tests should run in parallel

type TestContext

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

TestContext provides enhanced context for modern testing patterns

func NewTestContext

func NewTestContext(t *testing.T) *TestContext

NewTestContext creates a new modern test context following 2025 standards

func (*TestContext) AddCleanup

func (tc *TestContext) AddCleanup(fn func())

AddCleanup registers a cleanup function

func (*TestContext) Assertions

func (tc *TestContext) Assertions() *AssertionHelper

Assertions returns the assertion helper

func (*TestContext) Cleanup

func (tc *TestContext) Cleanup()

Cleanup executes all registered cleanup functions

func (*TestContext) Context

func (tc *TestContext) Context() context.Context

Context returns the test context with timeout

func (*TestContext) Fixtures

func (tc *TestContext) Fixtures() *FixtureManager

Fixtures returns the fixture manager

func (*TestContext) T

func (tc *TestContext) T() *testing.T

T returns the underlying testing.T

type TestDataFactory

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

TestDataFactory provides factory methods for creating test data

func NewTestDataFactory

func NewTestDataFactory() *TestDataFactory

NewTestDataFactory creates a new test data factory

func (*TestDataFactory) CreateTestNamespace

func (tdf *TestDataFactory) CreateTestNamespace() string

CreateTestNamespace generates a unique test namespace

func (*TestDataFactory) GenerateUniqueID

func (tdf *TestDataFactory) GenerateUniqueID(prefix string) string

GenerateUniqueID generates a unique test ID

type TestEnvironment

type TestEnvironment struct {
	Config    *TestConfig
	Namespace string
	Cleanup   []func()
}

TestEnvironment provides environment-specific testing utilities

func NewTestEnvironment

func NewTestEnvironment() *TestEnvironment

NewTestEnvironment creates a new test environment with proper configuration

func (*TestEnvironment) AddCleanup

func (te *TestEnvironment) AddCleanup(fn func())

AddCleanup registers a cleanup function

func (*TestEnvironment) SetupNamespace

func (te *TestEnvironment) SetupNamespace(factory *TestDataFactory) string

SetupNamespace creates and configures a test namespace

func (*TestEnvironment) TearDown

func (te *TestEnvironment) TearDown()

TearDown executes all cleanup functions

type TestFixtures

type TestFixtures struct {
	Scheme *runtime.Scheme

	Client client.Client

	Namespace string
}

func NewTestFixtures

func NewTestFixtures() *TestFixtures

type TestSuite

type TestSuite struct {
	Name string

	Description string

	Tests []TestCase
}

Jump to

Keyboard shortcuts

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