Files
Charon/.github/skills/test-backend-unit.SKILL.md

4.9 KiB

name, version, description, author, license, tags, compatibility, requirements, environment_variables, parameters, outputs, metadata
name version description author license tags compatibility requirements environment_variables parameters outputs metadata
test-backend-unit 1.0.0 Run Go backend unit tests without coverage analysis (fast execution) Charon Project MIT
testing
unit-tests
go
backend
fast
os shells
linux
darwin
bash
name version optional
go >=1.23 false
name description default required
CHARON_ENCRYPTION_KEY Encryption key for backend test runtime. Auto-generated ephemerally if missing/invalid. (auto-generated for test run) false
name type description default required
verbose boolean Enable verbose test output false false
name type description default required
package string Specific package to test (e.g., ./internal/...) ./... false
name type description
test_results stdout Go test output showing pass/fail status
category subcategory execution_time risk_level ci_cd_safe requires_network idempotent
test unit short low true false true

Test Backend Unit

Overview

Executes the Go backend unit test suite without coverage analysis. This skill provides fast test execution for quick feedback during development, making it ideal for pre-commit checks and rapid iteration.

Unlike test-backend-coverage, this skill does not generate coverage reports or enforce coverage thresholds, focusing purely on test pass/fail status.

Prerequisites

  • Go 1.23 or higher installed and in PATH
  • Backend dependencies installed (cd backend && go mod download)
  • Sufficient disk space for test artifacts

Usage

Basic Usage

Run all backend unit tests:

cd /path/to/charon
.github/skills/scripts/skill-runner.sh test-backend-unit

Test Specific Package

Test only a specific package or module:

.github/skills/scripts/skill-runner.sh test-backend-unit -- ./internal/handlers/...

Verbose Output

Enable verbose test output for debugging:

.github/skills/scripts/skill-runner.sh test-backend-unit -- -v

CI/CD Integration

For use in GitHub Actions or other CI/CD pipelines:

- name: Run Backend Unit Tests
  run: .github/skills/scripts/skill-runner.sh test-backend-unit

Parameters

Parameter Type Required Default Description
verbose boolean No false Enable verbose test output (-v flag)
package string No ./... Package pattern to test

Environment Variables

Variable Required Default Description
CHARON_ENCRYPTION_KEY No auto-generated for test run Backend test encryption key. If missing/invalid, an ephemeral 32-byte base64 key is generated for the run.

Outputs

Success Exit Code

  • 0: All tests passed

Error Exit Codes

  • Non-zero: One or more tests failed

Console Output

Example output:

ok      github.com/Wikid82/charon/backend/internal/handlers    0.523s
ok      github.com/Wikid82/charon/backend/internal/models      0.189s
ok      github.com/Wikid82/charon/backend/internal/services    0.742s

Examples

Example 1: Basic Execution

.github/skills/scripts/skill-runner.sh test-backend-unit

Example 2: Test Specific Package

.github/skills/scripts/skill-runner.sh test-backend-unit -- ./internal/handlers

Example 3: Verbose Output

.github/skills/scripts/skill-runner.sh test-backend-unit -- -v

Example 4: Run with Race Detection

.github/skills/scripts/skill-runner.sh test-backend-unit -- -race

Example 5: Short Mode (Skip Long Tests)

.github/skills/scripts/skill-runner.sh test-backend-unit -- -short

Error Handling

Common Errors

Error: package not found

Solution: Verify package path is correct; run go list ./... to see available packages

Error: build failed

Solution: Fix compilation errors; run go build ./... to identify issues

Error: test timeout

Solution: Increase timeout with -timeout flag or fix hanging tests

  • test-backend-coverage - Run tests with coverage analysis (slower)
  • build-check-go - Verify Go builds without running tests
  • security-check-govulncheck - Go vulnerability scanning

Notes

  • Execution Time: Fast execution (~5-10 seconds typical)
  • No Coverage: Does not generate coverage reports
  • Race Detection: Not enabled by default (unlike test-backend-coverage)
  • Idempotency: Safe to run multiple times
  • Caching: Benefits from Go test cache for unchanged packages
  • Suitable For: Pre-commit hooks, quick feedback, TDD workflows

Last Updated: 2025-12-20 Maintained by: Charon Project Team Source: Inline task command