testutil

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package testutil provides reusable test utilities for the vel CLI test suite.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureStdout

func CaptureStdout(t *testing.T, f func()) string

CaptureStdout captures stdout during function execution and returns the output as a string. The function is run synchronously and stdout is restored after completion.

func StripANSI

func StripANSI(s string) string

StripANSI removes ANSI escape codes from a string. This is useful for comparing terminal output that contains color codes.

func WithEnv

func WithEnv(t *testing.T, vars map[string]string, f func())

WithEnv runs a function with the specified environment variables set. After the function completes, all environment variables are restored to their original values (or unset if they didn't exist).

func WithTempDir

func WithTempDir(t *testing.T, f func(dir string))

WithTempDir creates a temporary directory, changes to it, runs the provided function, then restores the original working directory. The temp directory is automatically cleaned up by t.TempDir().

Types

This section is empty.

Jump to

Keyboard shortcuts

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