Skip to content

Testing

iomi edited this page Nov 25, 2026 · 9 revisions

Testing

Local

cargo test
cargo test signals::
cargo test --test cli fresh_package
cargo clippy --all-targets -- -D warnings
cargo fmt --check

The suite is roughly 900 tests: unit tests in each module and an end-to-end suite that runs the real binary against a local fake registry.

End-to-end shape

tests/cli.rs starts TcpListeners and points the binary at them through DEPVET_REGISTRY_BASE, DEPVET_OSV_BASE, DEPVET_EPSS_BASE, DEPVET_KEV_BASE, DEPVET_SCORECARD_BASE, DEPVET_MAVEN_REPO_BASE, and the other DEPVET_*_BASE seams. The cache is disabled except in tests that verify it.

Rules:

  • No test reaches the public internet or the real ~/.cache/dep-vet.
  • Scripted servers return status sequences, so retries and Retry-After are deterministic.
  • Failed requests cost a few hundred milliseconds because of bounded backoff; do not remove the sleeps.
  • Archives are built in the test process and served from the same fake host.

Hook gates

git config core.hooksPath .githooks
  • pre-commit vets staged lockfiles against HEAD and audits a newly added lockfile. Exit 2/3 blocks; warnings pass.
  • pre-push runs fmt, clippy, the full suite, then the workflow and MCP self-scans.

CI

.github/workflows/ci.yml runs:

  • test on Ubuntu, macOS, and Windows.
  • Formatting, clippy, and cargo-audit on Linux only.
  • dogfood: audit Cargo.lock, scan hand-written workflows, scan MCP configs; the generated release.yml goes to the step summary.
  • The weekly npm seed refresh and release workflows have their own checks.

Adding a test

  1. Prefer a unit test next to the rule or parser.
  2. If the change is user-visible through the CLI, add an end-to-end case with a fake server.
  3. For a bug, write the failing test first and keep it as the regression case.
  4. Every new finding id needs a KNOWN_FINDINGS entry and a confidence mapping; the allowlist completeness test enforces the first.

Clone this wiki locally