testing · git:20260324.7a91f3b · 2026-03-24 · sha256 b9ac33acce969243

testing git:20260324.7a91f3bA

Immutable. This exact content is served forever at /api/v1/blob/b9ac33acce969243.

---
description: Testing conventions
alwaysApply: true
---

# Testing Rules

## Test Files

- Test files live next to the code they test: `internal/led/engine_test.go`
- Use standard `testing` package — no external test frameworks
- Table-driven tests preferred for multiple cases

## Running Tests

```bash
go test ./...                    # All tests
go test ./internal/led/...       # Single package
go test -run TestFunctionName    # Single test
go test -v ./...                 # Verbose output
go test -race ./...              # Race detector
```

## Conventions

- Test function names: `TestMethodName_Scenario` (e.g. `TestEncodeColors_BufferLength`)
- Use `t.Errorf` or `t.Fatalf` — not `panic` or `log.Fatal` in tests
- Test exported behavior, not internal implementation details
- Mock external dependencies (shell commands, hardware), not internal services