go-testing

Applies focused Go testing patterns for unit tests, Bubbletea TUIs, and golden files.

Updated Jul 10, 2026
One-click install
npx skills add https://github.com/AD-Paladins/beaconator-web --skill go-testing-ad-paladins
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: go-testing
Source: https://github.com/AD-Paladins/beaconator-web/tree/main/.config/opencode/skills/go-testing
Command: npx skills add https://github.com/AD-Paladins/beaconator-web --skill go-testing-ad-paladins

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing consistent, maintainable Go tests is hard when projects mix pure functions, filesystem operations, TUI state machines, and rendered output. This Skill provides a decision framework that maps each kind of code under test to the right Go testing pattern, so tests stay deterministic, focused, and easy to review. ## Core Features & Use Cases - Pattern Selection via Decision Gates: Maps code under test (pure functions, file operations, TUI state, rendered output, external commands) to the correct test pattern such as table-driven tests, t.TempDir(), direct Model.Update() calls, teatest, or golden files. - Bubbletea and teatest Guidance: Distinguishes when to test Model.Update() directly for state transitions versus when to use teatest.NewTestModel() for full interactive flows. - Golden File Discipline: Enforces deterministic golden files updated only through the repo's -update flag, with a rerun-without-update verification step. - Use Case: While adding a new screen to a Bubbletea CLI, use this Skill to write a direct Update() test for the state transition, a golden file test for the rendered view, and a skippable integration test for the external command it shells out to. ## Quick Start Ask the assistant to write tests for a specific Go function or Bubbletea model following the go-testing patterns, then run the narrow package test before the broader suite.

Frequently Asked Questions about go-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write table-driven tests in Go?▼

Define a slice of anonymous structs with name, inputs, and expected outputs, then loop with t.Run(tt.name, ...) for each case. Name cases by scenario rather than input mechanics, and assert outputs, errors, and side effects explicitly.

How do I test a Bubbletea TUI model in Go?▼

Test state transitions by calling Model.Update() directly with a tea.Msg and asserting the resulting model state. Use teatest.NewTestModel() only for full interactive flows where you need to send messages and wait for the program to finish.

When should I use teatest instead of calling Update directly?▼

Use direct Model.Update() calls for single state transitions since they are faster and simpler. Reserve teatest for end-to-end interactive flows involving multiple messages, async commands, or final model inspection via tm.FinalModel(t).

How do golden file tests work in Go?▼

Add an -update flag that writes actual output to the golden file when set, otherwise read the golden file and compare it against actual output. Always rerun tests without -update after regenerating to confirm the diff is stable and deterministic.

How do I keep Go integration tests from slowing down the suite?▼

Guard tests that run external commands or slow flows with testing.Short() so they are skipped under go test -short. Run the narrow package test first, then the broader suite, and use small mocks around system boundaries where possible.