testutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecCmd

func ExecCmd(m tea.Model, cmd tea.Cmd) tea.Model

ExecCmd executes a Bubble Tea command synchronously, running it until all messages have been processed. This is essential for testing TEA applications where commands are normally async.

Usage:

m := NewModel()
ExecCmd(m, m.Init())
assert.Equal(t, expectedState, m.state)

func SetEnv

func SetEnv(t *testing.T, key, value string) func()

SetEnv sets an environment variable for the duration of a test. Returns a cleanup function that should be called with defer.

Usage:

cleanup := testutil.SetEnv(t, "HOME", tempDir)
defer cleanup()

func TempConfigDir

func TempConfigDir(t *testing.T) (string, func())

TempConfigDir creates a temporary directory for config testing. It returns the temp directory path and a cleanup function. The cleanup function should be called with defer.

Usage:

tempDir, cleanup := testutil.TempConfigDir(t)
defer cleanup()

func WriteTestConfig

func WriteTestConfig(t *testing.T, content string) (string, func())

WriteTestConfig writes a test config file to a temporary location. Returns the path to the config file and a cleanup function.

Usage:

configPath, cleanup := testutil.WriteTestConfig(t, "user_token: xoxb-test")
defer cleanup()

Types

This section is empty.

Jump to

Keyboard shortcuts

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