konflux-ci/integration-service/running-unit-tests
Claude Code and agent skill by konflux-ci/integration-service
- community
Checking that the SKILL.md file is still in the repository.
Use when running, writing, or troubleshooting unit tests for integration-service. Covers make test, envtest setup, suite patterns, mock loader, CRD discovery, coverage, and common test failures.
Install
npx vskill@latest install konflux-ci/integration-service/running-unit-testsSKILL.md
Running Unit Tests
Overview
Unit tests use Ginkgo v2 + Gomega with envtest (a local K8s API server). Every package has a *_suite_test.go that bootstraps envtest with CRDs, registers schemes, and starts a controller manager.
When to Use
- Running or debugging unit tests
- Adding tests to a new or existing package
- Troubleshooting envtest or CRD-related test failures
- Understanding the mock loader pattern
Quick Reference
| Command | What it does | |
|---|---|---|
make test | Full pipeline: manifests, generate, fmt, vet, envtest, download-crds, then go test ./... -coverprofile cover.out | |
make download-crds | Downloads CRD YAMLs from dependency modules (vendoring prunes non-Go files) | |
make envtest | Downloads setup-envtest tool | |
go test ./internal/controller/snapshot/... | Run tests for a single package | |
go test ./... -run TestName | Run a specific test by name |
Suite Setup Pattern
Every suite follows this structure (see any *_suite_test.go):
- CRD paths via
CRDDirectoryPaths— local CRDs fromconfig/crd/basesplus dependency CRDs found viatoolkit.GetRelativeDependencyPath() - Scheme registration — add all API types (
applicationapiv1alpha1,tektonv1,releasev1alpha1,v1beta2) - Manager creation —
ctrl.NewManager()withMetrics.BindAddress: "0"(disables metrics to avoid port conflicts) andLeaderElection: false - Cache setup — call
cache.Setup*Cache(k8sManager)functions before starting manager - Start manager in goroutine —
go func() { defer GinkgoRecover(); k8sManager.Start(ctx) }() - Cleanup —
cancel()context andtestEnv.Stop()inAfterSuite
CRD directory paths are relative to the suite file location. Adjust depth (.., ../..) based on package nesting.
Mock Loader Pattern
loader/loader_mock.go intercepts resource loading via context keys:
Each resource type has a corresponding *ContextKey constant (34 keys available).
Test Conventions
- BDD structure:
Describe>Context("When...")>It("should...") - Use
Eventuallyfor async assertions, nevertime.Sleep - Always
Get()afterCreate()/Update()to ensure server-side state - Test idempotency: calling Reconcile twice must produce the same result
ginkgolinteris enabled — follow its conventions
Common Mistakes
| Problem | Fix | |
|---|---|---|
no matches for kind "X" | Missing CRD in CRDDirectoryPaths — add the dependency path | |
| Port conflict on metrics | Ensure Metrics.BindAddress: "0" in manager options | |
make test fails on missing CRDs | Run make download-crds — vendoring prunes YAML files | |
| Stale generated code | Run make generate manifests before testing | |
| Tests pass locally, fail in CI | Check go mod tidy and make fmt — CI fails on uncommitted changes |
Coverage
- Tool: codecov with flag
unit-tests - Patch target: 85% (see estimating-codecov-patch-coverage for the local estimate)
- Project coverage remains informational
- Ignores:
**/zz_generated*,e2e-tests/**, vendor
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/running-unit-tests/SKILL.md
Popularity
- 7-day trend score
- 0
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
[](https://verified-skill.com/skills/konflux-ci/integration-service/running-unit-tests)