Husky testing guide
Husky uses a layered test strategy:
- package-level unit tests for validation, scheduling, executor logic, store queries, API handlers, auth, and notifications
- integration suites for daemon lifecycle, pipelines, catchup, reload, SLA, healthchecks, and API behavior
- frontend tests for dashboard utilities
- manual end-to-end scenarios under
testproject/
Fast local workflow
Run everything:
make test
Run Go tests only:
go test ./...
Run frontend tests only:
cd web
npm ci --silent
npm test
Integration suites
The main integration-heavy Go packages are:
go test ./cmd/huskyd ./tests
Important files include:
cmd/huskyd/recovery_integration_test.gocmd/huskyd/phase4_integration_test.gotests/integration_test.gotests/daemon_integration_test.gotests/phase4_integration_test.go
Run one integration test by name:
go test ./cmd/huskyd -run TestIntegration_FullPipeline_ExecutesEndToEnd -v
go test ./tests -run TestIntegration_RunReason_AuditFilter_AndNotificationTemplate -v
What is covered where
Config and schema
internal/config/*_test.go- validates enum values, durations, time formats, timezone handling, tags, integrations,
sla < timeout, and strict-mode rules
DAG and scheduling
internal/dag/dag_test.gointernal/scheduler/schedule_test.gointernal/scheduler/sla_test.go
These cover topological ordering, cycle detection, schedule evaluation, timezone logic, and DST anomalies.
Executor and subprocess behavior
internal/executor/executor_test.gointernal/executor/output_test.gointernal/executor/global_env_test.go
These cover:
- stdout / stderr capture
- timeouts and cancellation
- healthchecks
- output capture modes
- global vs per-job env layering
Store and persistence
internal/store/store_test.gointernal/store/vacuum_test.go
These cover migrations, CRUD behavior, retention vacuuming, and query semantics.
API, auth, dashboard, notifications
internal/api/server_test.gointernal/api/dashboard_test.gointernal/auth/auth_test.gointernal/notify/dispatcher_test.go
Manual scenario project
testproject/ contains scenario folders for higher-confidence manual validation.
Examples include:
- basic scheduling
- pipelines
- reliability
- SLA and healthchecks
- notifications
- tags
- audit trail
- timezone
- catchup
- validation errors
Use these when changing product behavior that spans multiple subsystems.
Recommended workflow for feature work
- run focused unit tests for the package being changed
- run the targeted integration package
- run
go test ./... - if dashboard or embedded assets changed, run
make buildormake web - if behavior is user-facing and cross-cutting, validate against
testproject/
Example commands
Build and run full suite:
make build
go test ./...
Target only integration suites:
go test ./cmd/huskyd ./tests -v
Target dashboard source tests:
cd web && npm test
Notes for documentation-driven development
When changing documented behavior, update:
- root
README.md - the relevant file under
docs/ docs/task.mdif a tracked documentation deliverable changed state
dev-docs/ is archived planning material and should not be treated as the source of truth for current runtime behavior.