baphled/dotopencode/test-fixtures-go

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Factory-go and gofakeit for Go test fixtures

Install

npx vskill@latest install baphled/dotopencode/test-fixtures-go

SKILL.md

Skill: test-fixtures-go

What I do

I provide expertise in generating realistic test data for Go using factory-go patterns and gofakeit. I specialise in the functional options pattern for flexible, composable, and type-safe test fixtures.

When to use me

  • Creating realistic mock data for Go unit and integration tests.
  • Implementing the functional options pattern for object builders.
  • Need random but structured data (UUIDs, emails, names) in tests.
  • DRYing up test setup code across multiple Go spec files.

Core principles

  1. Realistic Data — Use gofakeit to generate data that mimics production values (valid emails, real-looking names).
  2. Functional Options — Prefer func(*Type) options for builders to keep the API clean and extensible.
  3. Type Safety — Ensure fixtures return the correct types and handle mandatory fields by default.
  4. Minimal Setup — Fixtures should return a valid object with zero arguments; override only what's needed.

Patterns & examples

Functional Options Pattern (Recommended)
go
type User struct {
ID string
Email string
FirstName string
Role string
}
func NewUser(opts ...func(*User)) *User {
user := &User{
ID: gofakeit.UUID(),
Email: gofakeit.Email(),
FirstName: gofakeit.FirstName(),
Role: "user",
}
for _, opt := range opts {
opt(user)
}
return user
}
// Options
func WithEmail(e string) func(*User) { return func(u *User) { u.Email = e } }
func WithRole(r string) func(*User) { return func(u *User) { u.Role = r } }
// Usage
admin := NewUser(WithRole("admin"))
Integration with Ginkgo
go
var _ = Describe("UserService", func() {
var user *User
BeforeEach(func() {
user = NewUser(WithRole("admin"))
})
It("grants admin privileges", func() {
Expect(user.Role).To(Equal("admin"))
})
})

Anti-patterns to avoid

  • ❌ Hardcoded Constants — Leads to "mystery guest" problems and fragile tests.
  • ❌ Manual Struct Literals — Duplicates setup logic and makes adding fields painful.
  • ❌ Over-complex Builders — If a fixture needs 10+ options, the struct likely needs refactoring.

KB Reference

~/vaults/baphled/3. Resources/Knowledge Base/AI Development System/Skills/Testing-BDD/Test Fixtures Go.md

Related skills

  • test-fixtures - Universal patterns for test data.
  • ginkgo-gomega - Go BDD testing framework.
  • golang - Core Go language idioms.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
1
Repository forks
1
7-day trend score
8

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/baphled/dotopencode/test-fixtures-go/badge)](https://verified-skill.com/skills/baphled/dotopencode/test-fixtures-go)

Something wrong with this skill or its page? Tell us.