go-testing_skill
- Shell
1.3k
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill gentleman-programming/gentleman.dots --skill go-testing- SKILL.md8.3 KB
Overview
This skill documents practical Go testing patterns used in Gentleman.Dots, with focused guidance for Bubbletea TUI testing, teatest integration, and golden file comparisons. It collects decision rules, concrete patterns, and file organization tips to make tests reliable and maintainable. Use it to standardize how you write unit, integration, and visual tests for Go TUI code.
How this skill works
The skill describes proven test idioms: table-driven tests for pure logic, direct Model.Update() assertions for Bubbletea state transitions, teatest-based interactive flows for end-to-end TUI behavior, and golden file comparisons for verifying rendered output. It also provides a decision tree to choose the right approach and examples for cursor navigation, screen transitions, mocking system info, and trainer validation. Commands and test file layout show how to run and organize tests.
When to use it
- Writing Go unit tests for pure functions and logic
- Testing Bubbletea Model state changes and key handling
- Creating integration tests for interactive TUI flows with teatest
- Verifying visual output with golden file testing
- Adding test coverage for system interactions or file operations
Best practices
- Prefer table-driven tests for multiple input/output cases to reduce duplication
- Test Bubbletea models by calling Update() and inspecting resulting Model state
- Use teatest.NewTestModel() to simulate key sequences and wait for completion
- Keep golden files under testdata/ and provide an --update flag to refresh them
- Mock external system dependencies via interfaces and use t.TempDir() for filesystem isolation
- Use go test -short to skip slow integration tests in CI or local quick runs
Example use cases
- Validate cursor movement and boundary conditions using parameterized table tests
- Assert screen transitions by sending tea.KeyMsg actions and checking Model.Screen
- Exercise a full interactive installer flow with teatest, sending keys and verifying final model
- Compare rendered views for a given screen size against stored golden files
- Test installer steps by injecting a mocked SystemInfo and verifying generated steps
FAQ
Use golden files when output is complex or visual (TUI views) and you want a stable textual snapshot to detect regressions. Provide an update flag to regenerate golden files when intentional changes occur.
How do I test Bubbletea key handling deterministically?
Call Model.Update() directly with tea.KeyMsg for unit tests, and use teatest.NewTestModel() for end-to-end flows where you need timing and animation handling.