konflux-ci/capo/testing

Claude Code and agent skill by konflux-ci/capo

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when writing new unit or integration tests for capo, adding test cases to integration_test.go, structuring test expectations with PackageMetadataItem, or choosing between unit and integration test scope

Install

npx vskill@latest install konflux-ci/capo/testing

SKILL.md

Testing

Overview

Capo uses build-tag-separated test suites: //go:build unit for fast tests without buildah, //go:build integration for almost end-to-end tests that build real container images and scan them.

When to Use

  • Adding a new test case for a Containerfile pattern
  • Verifying capo output for a new COPY/mount scenario
  • Unsure whether to write a unit or integration test

Unit vs Integration

AspectUnit (//go:build unit)Integration (//go:build integration)
Run withmage testmage integrationTest
Needs buildahNoYes (>= 1.44.0)
Tests whatParsing, source tracing, path matchingFull build-scan-compare cycle
Locationpkg/*_test.go per packagepkg/integration_test.go
PatternTable-driven map[string]struct{}TestCase with BuildDefinition

Rule of thumb: if it needs buildah build or storage.Store, it's integration. Everything else is unit.

Adding an Integration Test

  1. Add entry to testCases map in TestIntegration:
go
"Description of what this test verifies": {
TestImage: BuildDefinition{
ContainerfileContent: `FROM localhost/my-base:latest AS builder
RUN something
FROM scratch
COPY --from=builder /app /app`,
ContextDirectory: "../testdata/image_content",
},
BuilderImages: []BuildDefinition{
{
Tag: "localhost/my-base:latest",
ContainerfileContent: `FROM scratch
COPY some.file /app/some.file`,
ContextDirectory: "../testdata/image_content",
},
},
ExpectedResult: PackageMetadata{
Packages: []PackageMetadataItem{
{
PackageURL: "pkg:golang/example.com/pkg@v1.0.0",
OriginType: "builder",
Pullspec: "localhost/my-base@sha256:dummy",
StageAlias: "builder",
},
},
},
},
  1. Key fields:
  • Tag — auto-normalized (adds localhost/, :latest if missing)
  • ContainerfileContent — inline only, no file paths
  • ContextDirectory — relative to pkg/, typically ../testdata/image_content
  • Pullspec in expected — use @sha256:dummy, digests are stripped during comparison
  1. Comparison uses go-cmp with:
  • cmpopts.SortSlices — order-independent matching on PackageURL
  • cmpopts.EquateEmpty — nil and empty slices are equal
  • cmp.FilterPath on Pullspec — strips digests before comparing

Where to Add Tests

Change typeTest location
Containerfile parsing logicpkg/containerfile/containerfile_test.go
Source tracing behaviorpkg/scan_test.go
Content extraction logicpkg/integration_test.go
Buildprobe behaviorpkg/probe/probe_test.go
Build arg handlingpkg/buildargs/buildargs_test.go
Bug fixTest that reproduces the bug before the fix

Bug Fix Workflow

Always use test-driven approach for bug fixes:

  1. Write a failing test first — reproduce the bug with a test case that fails on the current code
  2. Verify the test fails — run mage test and confirm the failure matches the reported bug

(redirect test logs to file for better readability and audit purposes)

  1. Fix the bug — make the minimal change to fix the issue
  2. Verify the test passes — run mage test again, the previously failing test should now pass
  3. Check for regressions — run mage lint and mage integrationTest if applicable

Never fix first and test later — writing the test first ensures you understand the bug and that the fix actually addresses it.

Common Mistakes

  • Missing //go:build unit or //go:build integration tag — tests won't run
  • Forgetting exclude_graphdriver_btrfs — handled by mage, but breaks with raw go test
  • Missing BuilderImages — builder base must exist in storage before test image build
  • Using file paths in ContainerfileContent — only inline content works

Additional Resources

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

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/konflux-ci/capo/testing/badge)](https://verified-skill.com/skills/konflux-ci/capo/testing)

Something wrong with this skill or its page? Tell us.