Documentation
¶
Index ¶
- func AssertFileContains(t *testing.T, path, content string)
- func CaptureOutput(_ *testing.T, fn func()) (stdout, stderr string)
- func CompareJSON(t *testing.T, expected, actual string)
- func CreateTestEnvFile(t *testing.T, path string, vars map[string]string)
- func CreateTestServer(_ *testing.T, routes map[string]http.Handler) *httptest.Server
- func LoadFixture(t *testing.T, name string) []byte
- func SetEnv(t *testing.T, vars map[string]string)
- func WriteFixture(t *testing.T, path, content string)
- type MockResponse
- type TestConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertFileContains ¶
AssertFileContains checks if a file contains a specific string
func CaptureOutput ¶
CaptureOutput captures stdout and stderr
func CompareJSON ¶
CompareJSON compares two JSON strings
func CreateTestEnvFile ¶
CreateTestEnvFile creates a test .env file
func CreateTestServer ¶
CreateTestServer creates a test HTTP server with predefined routes
func LoadFixture ¶
LoadFixture loads a fixture file
func WriteFixture ¶
WriteFixture writes a fixture file
Types ¶
type MockResponse ¶
MockResponse creates a mock HTTP response
func (MockResponse) ServeHTTP ¶
func (m MockResponse) ServeHTTP(w http.ResponseWriter, _ *http.Request)
ServeHTTP implements http.Handler
type TestConfig ¶
TestConfig holds test configuration
func NewTestConfig ¶
func NewTestConfig(t testing.TB) *TestConfig
NewTestConfig creates a new test configuration.
Sets DOTENV_CONFIG_DIR + HOME to fresh temp paths so the CLI under test cannot leak into the developer's real ~/.dotenv account store (which would otherwise trigger OAuth refresh against a real API and hit rate limits).
Layout: tempDir/ (HOME) -> .dotenv/ (DOTENV_CONFIG_DIR via UserHomeDir) -> config.yaml. This matches the production layout config.ConfigPath() returns.
func (*TestConfig) RedirectUI ¶
func (tc *TestConfig) RedirectUI(t *testing.T, stdout, stderr *bytes.Buffer)
RedirectUI swaps ui.Stdout / ui.Stderr to the supplied buffers for the lifetime of the test. Tests that assert on Print*-produced text need this because cobra's SetOut/SetErr only captures cobra's own writes.
func (*TestConfig) WriteConfig ¶
func (tc *TestConfig) WriteConfig(t testing.TB, cfg interface{})
WriteConfig writes a test configuration file.
Legacy compatibility: if the supplied config carries the old `contexts` shape, this method translates the first context into the new accounts/ account_manager format via the production AccountManager so the CLI under test can authenticate. Tests written for the modern shape pass through unchanged.