test-conventions
Testing standards for this Go project. Use when writing tests, adding test cases, or discussing test coverage.
Packaged view
This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.
Install command
npx @skill-hub/cli install feraudet-file-viewer-test-conventions
Repository
Skill path: .claude/skills/test-conventions
Testing standards for this Go project. Use when writing tests, adding test cases, or discussing test coverage.
Open repositoryBest for
Primary workflow: Write Technical Docs.
Technical facets: Full Stack, Tech Writer, Testing.
Target audience: everyone.
License: Unknown.
Original source
Catalog source: SkillHub Club.
Repository owner: feraudet.
This is still a mirrored public skill entry. Review the repository before installing into production workflows.
What it helps with
- Install test-conventions into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
- Review https://github.com/feraudet/file-viewer before adding test-conventions to shared team environments
- Use test-conventions for development workflows
Works across
Favorites: 0.
Sub-skills: 0.
Aggregator: No.
Original source / Raw SKILL.md
---
name: test-conventions
description: Testing standards for this Go project. Use when writing tests, adding test cases, or discussing test coverage.
allowed-tools: Read, Grep, Glob, Bash
---
# Test Conventions
## Test Structure
Tests should be placed in `main_test.go` alongside `main.go`.
### Table-Driven Tests
```go
func TestSlugify(t *testing.T) {
tests := []struct {
name string
input string
expected string
}{
{"simple text", "Hello World", "hello-world"},
{"with special chars", "Hello! World?", "hello-world"},
{"with HTML", "<b>Bold</b>", "bold"},
{"empty", "", "heading-"}, // starts with hash prefix
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := slugify(tt.input)
if !strings.HasPrefix(result, tt.expected) && result != tt.expected {
t.Errorf("slugify(%q) = %q, want %q", tt.input, result, tt.expected)
}
})
}
}
```
### HTTP Handler Tests
```go
func TestHandler(t *testing.T) {
req := httptest.NewRequest("GET", "/test.md", nil)
w := httptest.NewRecorder()
handler(w, req)
if w.Code != http.StatusOK {
t.Errorf("status = %d, want %d", w.Code, http.StatusOK)
}
if !strings.Contains(w.Body.String(), "<!DOCTYPE html>") {
t.Error("response should contain HTML doctype")
}
}
```
## Test Commands
```bash
# Run all tests
go test -v
# Run specific test
go test -v -run TestSlugify
# With coverage
go test -cover
# Generate coverage report
go test -coverprofile=coverage.out && go tool cover -html=coverage.out
```
## What to Test
### Priority 1: Core Rendering
- `renderMarkdown()` - All Markdown syntax variants
- `renderJSON()` - Valid/invalid JSON, nested structures
- `slugify()` - Edge cases, special characters
### Priority 2: HTTP Routing
- Path resolution logic
- Query parameter handling
- Asset endpoint security
- Content-Type headers
### Priority 3: Helper Functions
- `replaceEmojis()`
- `processInline()` (if extracted)
## Test File Requirements
When testing file rendering, create temp files:
```go
func TestRenderFile(t *testing.T) {
tmpDir := t.TempDir()
testFile := filepath.Join(tmpDir, "test.md")
os.WriteFile(testFile, []byte("# Hello"), 0644)
content, class := renderFile(testFile)
// assertions...
}
```