cre-test
Skill84 starsChanged 33 days agoApache-2.0View on GitHub
Use when writing, running, or debugging tests in this repo. Covers the testutil.TestCaseParser golden-file pattern, integration tests, golden file regeneration, and the full verification suite.
In this repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- managing-openvexSkill
- release-notesSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
When in doubt: use testutil.TestCaseParser.
- Distinctive: line 74
Never regenerate blindly: Before touching golden files:
- Very specific: line 75
Read the existing expected.json
- Distinctive: line 95
After regeneration, always review the diff before considering the test complete.
- Very specific: line 120
Use generateNodes in input_config.yaml instead of explicit Node objects when you only need uniform nodes:
- Distinctive: line 138
Do not present failing tests to the user.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CRE Test Skill
When to Use
- Writing new unit or integration tests
- Deciding whether to use testutil.TestCaseParser or plain table tests
- Regenerating golden files after an intentional change
- Running a specific test or the full suite
- Debugging a failing integration test
Test Pattern Decision
Always use testutil.TestCaseParser (defined in pkg/testutil/) for structured output in these packages, which already follow the pattern:
pkg/catalog/,pkg/certification/,pkg/cluster/,pkg/controller/,pkg/goodput/,pkg/nodemonitor/cel/,pkg/orchestration/,pkg/platform/,pkg/podlogs/,pkg/render/,pkg/report/,pkg/workload/,pkg/workloadrun/,cmd/manager/,test/helm/
Plain table-driven tests are acceptable only for genuinely trivial helpers with no structured output worth snapshotting:
pkg/gpu/,pkg/naming/,pkg/nccl/,pkg/threshold/,pkg/numstr/,pkg/noderesults/,pkg/setup/- Nil-safety pins, concurrency guards, and single-value assertions anywhere, including inside the packages above.
pkg/controller/status_test.go(retry budget) andpkg/controller/parser_cache_test.go(cache identity) are the live examples. test/releasepolicy/andtest/docspolicy/are table-driven by design, running shell extracted from workflow YAML against accept and reject cases.
When in doubt: use testutil.TestCaseParser. It makes failures readable and lets you update expectations in one command instead of editing inline structs.
testutil.TestCaseParser Pattern
Each test case is a directory under pkg/<package>/testdata/<subdir>/:
testdata/
my-feature/
my-case/
input.yaml # or input_*.yaml
expected.json # golden outputMinimal test:
func TestMyFeature(t *testing.T) {
p := &testutil.TestCaseParser{Subdir: "my-feature"}
p.TestDir(t, func(tc *testutil.TestCase) error {
// parse tc.Inputs["input.yaml"]
// run your function
b, err := json.MarshalIndent(result, "", " ")
if err != nil {
return err
}
tc.Actual = string(b) + "\n"
return nil
})
}See pkg/catalog/gpu_defaults_test.go as the canonical reference.
Running Tests
# Full suite (unit + integration)
make test
# Single unit test
go test ./pkg/workload/ -run TestAdapterForSpec -v
# Single integration test case
KUBEBUILDER_ASSETS="$(bin/setup-envtest use -p path)" \
go test ./cmd/integration/ -v -timeout 600s -count=1 \
-run TestIntegration/reconcile/job-checkpoint-restartGolden File Regeneration
Never regenerate blindly. Before touching golden files:
- Read the existing
expected.json - Understand exactly which fields will change and why
- Confirm the change is an expected consequence of the code change
- Get explicit user permission
Then regenerate. Unit golden files live beside their package and are regenerated
by that package's own test command; make test-integration only rewrites the
integration goldens under cmd/integration/testdata/:
TESTUTIL_UPDATE_EXPECTED=true go test ./pkg/report/ # unit goldens
TESTUTIL_UPDATE_EXPECTED=true make test-integration # integration goldensOr for a specific integration case:
TESTUTIL_UPDATE_EXPECTED=true KUBEBUILDER_ASSETS="$(bin/setup-envtest use -p path)" \
go test ./cmd/integration/ -v -timeout 600s -count=1 \
-run TestIntegration/reconcile/<case-name>After regeneration, always review the diff before considering the test complete. A golden file that auto-passes is not a test.
Integration Test Structure
Each case under cmd/integration/testdata/reconcile/<case-name>/:
input_client_objects.yaml # k8s objects to pre-populate
input_config.yaml # waitFor condition + collect list
expected.json # golden snapshot of collected resourcesinput_config.yaml shape:
waitFor:
kind: Workflow
name: my-workflow
namespace: default
condition: InProgress
reason: JobRunning
collect:
- kind: Workflow
name: my-workflow
namespace: defaultUse generateNodes in input_config.yaml instead of explicit Node objects when you only need uniform nodes:
generateNodes:
count: 2
providerID: "gce://my-project/us-central1-a/instance-1"
labels:
nvidia.com/gpu.product: NVIDIA-GB200-NVL72Verification Suite (run in order)
make manifests generate # after *_types.go changes
make lint-fix
make build
make testDo not present failing tests to the user. Fix and re-run. Ask for help after two failed attempts.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

