testutil

package
v0.0.0-...-8f1971e Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTestAgent

func CreateTestAgent(namespace, name string) *v1alpha2.Agent

CreateTestAgent creates a test Agent resource for testing.

func CreateTestDir

func CreateTestDir(t *testing.T, fs afero.Fs, path string)

CreateTestDir creates a directory in the filesystem for testing.

func CreateTestFile

func CreateTestFile(t *testing.T, fs afero.Fs, path, content string)

CreateTestFile writes a file to the filesystem for testing.

func CreateTestNamespace

func CreateTestNamespace(name string) *corev1.Namespace

CreateTestNamespace creates a test Namespace resource for testing.

func CreateTestSecret

func CreateTestSecret(namespace, name string, data map[string]string) *corev1.Secret

CreateTestSecret creates a test Secret resource for testing.

func FileExists

func FileExists(t *testing.T, fs afero.Fs, path string) bool

FileExists checks if a file exists in the filesystem.

func IsDockerAvailable

func IsDockerAvailable() bool

IsDockerAvailable returns true if Docker daemon is available.

func IsKindAvailable

func IsKindAvailable() bool

IsKindAvailable returns true if kind is available.

func MockAgentResponse

func MockAgentResponse(agents []api.AgentResponse) http.HandlerFunc

MockAgentResponse returns a mock AgentResponse handler.

func MockErrorResponse

func MockErrorResponse(statusCode int, message string) http.HandlerFunc

MockErrorResponse returns a mock error response handler.

func MockSessionResponse

func MockSessionResponse(sessions []*api.Session) http.HandlerFunc

MockSessionResponse returns a mock SessionResponse handler.

func MockVersionResponse

func MockVersionResponse(version string) http.HandlerFunc

MockVersionResponse returns a mock version response handler.

func NewFakeControllerClient

func NewFakeControllerClient(t *testing.T, objects ...client.Object) client.Client

NewFakeControllerClient creates a fake controller-runtime client with the kagent scheme. Useful for testing reconcilers and CRD interactions.

func NewFakeK8sClientset

func NewFakeK8sClientset(objects ...runtime.Object) *fake.Clientset

NewFakeK8sClientset creates a fake Kubernetes clientset with optional initial objects. Useful for testing kubectl/client-go interactions.

func NewMemFS

func NewMemFS() afero.Fs

NewMemFS creates an in-memory filesystem for testing. This allows tests to run without touching the actual filesystem.

func NewMockHTTPServer

func NewMockHTTPServer(t *testing.T, handler http.HandlerFunc) *httptest.Server

NewMockHTTPServer creates a test HTTP server for mocking API responses.

func ReadTestFile

func ReadTestFile(t *testing.T, fs afero.Fs, path string) string

ReadTestFile reads a file from the filesystem for testing assertions.

func RequireDocker

func RequireDocker(t *testing.T)

RequireDocker skips the test if Docker is not available. Use this for integration tests that require Docker daemon.

func RequireKind

func RequireKind(t *testing.T)

RequireKind skips the test if kind is not available. Use this for integration tests that require kind cluster.

Types

This section is empty.

Jump to

Keyboard shortcuts

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