Skip to main content

Testing

The pyramid as it exists in the repository. Everything below runs without a hand-started database or broker: integration tests boot their own Postgres and Kafka with testcontainers (the fitness tests TestPostgresIntegrationTestsUseTestcontainers and TestKafkaIntegrationTestsUseTestcontainers fail a test that reads DATABASE_URL or KAFKA_BROKERS and skips).

LayerWhereRun withNeeds
Unit and handler testsinternal/domain/*, internal/application/usecases, internal/adapters/**, cmd/* (*_test.go)make test (go test ./... -race)nothing
Behaviour (godog / Gherkin)features/make bdd (go test ./... -run TestFeatures -v)nothing (in-memory test doubles, Strict: true)
Integrationfiles named *_integration_test.go under the build tag integrationmake integration (go test -tags=integration ./... -race -count=1)Docker only
Contractevent catalogue, MCP tool registry, OpenAPI/AsyncAPI lintmake arch-test for the first two; spectral in CI for the specsnothing / Node
Mutationinternal/domain/<pkg> with gremlinsmake mutation, make mutation-fullgremlins v0.6.0
Architecture fitnessinternal/architecturemake arch-testnothing

Unit and handler tests​

About 80 test files. The domain packages (book, calendar, offer, policy, promise, search, shared) are pure and tested without doubles. Use cases are tested over the in-memory adapters in internal/adapters/outbound/memory (test doubles that cmd/** must never import, enforced by TestRuntimeBinaryHasNoInMemoryAdapters). The HTTP adapter has httptest handler tests, idempotency and readiness tests; the consumer has loop tests with a fake reader (retry, dead-letter, commit-after-handle); the outbox relay has its own tests. make coverage runs the whole suite with -race and gates 90 % over internal/domain/... and internal/application/... (the only place the scope is defined; repo_lint R11 rejects a workflow that redefines it).

Godog features​

Ten files, 135 scenario definitions (git grep -c -E "^[[:space:]]*Scenario" -- 'features/*.feature', which counts Scenario and Scenario Outline); the runner executes them as 161 scenarios because the Examples rows of the Outlines expand (the 161 scenarios (161 passed) line of go test ./features -run TestFeatures -count=1 -v).

FileDefinitionsCovers
quote_rules.feature29QuoteDeliveryOffers rules: scorecard handicap, offer expiry and policy knobs, packages per order, constraint naming, delivery wave rule, SAME_DAY, shipment grouping, tier order deadline
lifecycle_rules.feature25promise lifecycle: hold expiry sweep and confirm, cancel, flag at risk and re-promise, predicted late (ADR 0021), judgement, shared tracking numbers (ADR 0025), projection guards
capacity_rules.feature18PromiseBook: book share, hold, exhaustion, release, close at cutoff, and the availability a quote sells (ADR 0015)
promises.feature13make, confirm, hold expiry, capacity, revisions
rest.feature11the REST contract through the real router
quoting.feature9the witness-path search, tiers, constraints
keeping.feature9judging kept or broken, re-promising on risk
calibration.feature5promise calibration (ADR 0020)
consolidated.feature5the opt-in consolidated tier (ADR 0024)
stale_facts_rules.feature11capacity facts, node status and listing suppression that arrive out of order never overwrite a newer one; a retired node is terminal (ADR 0028, ADR 0029)

The three *_rules.feature files pin rules the context's documentation states (ADR 0002, 0003, 0015, 0021, 0022, 0025). A scenario that describes a documented rule the code does not yet honour is tagged @known-bug: it is excluded by default (BDD_TAGS defaults to ~@known-bug) and runs alone with BDD_TAGS=@known-bug, where it must fail. No scenario carries the tag today.

The runner is features/features_test.go (TestFeatures, Paths: ".", Strict: true, so an undefined step fails); steps live in features/steps_*_test.go. No Go file may sit at the repository root (TestNoGoFilesAtRepoRoot).

Integration tests​

Ten files tagged integration: the Postgres adapter (main_integration_test.go, repositories_integration_test.go, outbox_integration_test.go, outbox_trace_integration_test.go, window_time_zone_integration_test.go), the idempotency middleware (internal/adapters/inbound/http/idempotency_integration_test.go, the replay-class template idempotency_replay_classes_integration_test.go and idempotency_replay_extra_integration_test.go, and cmd/api/idempotency_replay_integration_test.go: a refused concurrent-update and a full book through the real router release their key, ADR 0031) and the three binaries (cmd/api/main_integration_test.go, cmd/api/e2e_integration_test.go, cmd/mcp/main_integration_test.go, cmd/a2a/main_integration_test.go). cmd/api/e2e_integration_test.go boots the real entry point on testcontainers Postgres and Kafka, proves the outbox publishes, and stops Kafka to prove /readyz goes 503 naming kafka while /healthz stays 200 and a write is still accepted.

Contract tests​

  • Events: TestEventCatalogueMatchesContract (internal/architecture/catalogue_fitness_test.go) ties the event catalogue in code to apis/asyncapi.yaml; TestCloudEventsOnly forbids any non-CloudEvents envelope.
  • MCP: TestToolSurface, TestWriteVerbSensorFailsOnWriteNames and TestToolRegistryGolden (internal/adapters/inbound/mcp/governance_test.go) pin the six tools, forbid write verbs and pin the registry (TestToolRegistryGolden).
  • REST and events specs: spectral lint of apis/openapi.yaml and apis/asyncapi.yaml (CI job api-lint, --fail-severity=warn). There is no test that replays the OpenAPI document against the live router beyond features/rest.feature.

Mutation tests​

.gremlins.yaml is read by every gremlins run: one worker, timeout-coefficient: 30, thresholds efficacy: 87 and mutant-coverage: 94. make mutation loops over every package under internal/domain/ (shared, calendar, policy, offer, book, promise, search) and stops on the first failure; the CI job mutation-fast does the same on every push and PR; make mutation-full (job mutation, weekly and manual) runs the whole ./internal/domain tree. The measured efficacy per package is recorded in the file's header (weakest: search, 87.88-88.89 %).

Fitness tests​

make arch-test runs internal/architecture (31 test functions). The layer rule is TestHexagonalArchitecture; the others each guard one fleet rule:

TestGuards
TestMCPAdapterDependencyRule, TestA2AAdapterDependencyRule, TestA2AAdapterIsReadOnly, TestNoOutboundA2AClientthe MCP and A2A adapters are read-only and call no sibling
TestNoAuthMiddlewareReintroducedno authentication middleware on any surface
TestRuntimeBinaryHasNoInMemoryAdapters (+ SensorBites)cmd/** never links the memory adapters
TestNoGoFilesAtRepoRoot (+ variants)no Go file at the root
TestOutboxRelaysPassAttemptCapevery relay is built WithMaxAttempts
TestKafkaWritersSetRequiredAcks, TestKafkaWriterTopicNotSetTwice, TestDeadLetterCallsGuardCancellationwriter settings and dead-letter shutdown behaviour
TestKafkaConsumerGroupNeverHardcodedInline, TestReplayConsumersSetCommitIntervalstable group ids from the environment; no async commit
TestPostgresIntegrationTestsUseTestcontainers, TestKafkaIntegrationTestsUseTestcontainersintegration tests own their infrastructure
TestNoEventEnvelopeToggleOrFlatEnvelope, TestCloudEventsOnly, TestEventCatalogueMatchesContractCloudEvents 1.0 structured mode only; catalogue equals contract
TestMCPOptionalToolInputsCarryOmitemptyoptional MCP inputs are optional in the schema

Make targets​

TargetEffect
make checkfmt-check vet build lint test, the pre-push gate (lefthook runs it on push)
make check-allcheck plus coverage arch-test bdd
make check-fastfmt-check vet arch-test plus tests of the packages changed against HEAD (agent Stop hook)
make coveragethe 90 % gate
make integrationtestcontainers suite, not part of check
make mutation / make mutation-fullgremlins
make vulngovulncheck ./...
make guide-lint, make harness-testagent-guide and hook checks

Helm chart tests are outside make: bash charts/delivery-promise/tests/render_test.sh and python3 charts/delivery-promise/tests/test_service_selectors.py. The web remote has its own suite (cd web && npm run lint && npx tsc -b && npm test && npm run build).

CI jobs (.github/workflows/ci.yml)​

Triggers: push and pull request on main and develop, a weekly Monday 06:00 UTC schedule and manual dispatch.

JobRunsBlocking
lintgolangci-lint v2.14.0yes
guide-lintscripts/harness/guide_lint.py, test_hook.pyadvisory (continue-on-error)
complexitygocyclo, gocognit, cyclop, funlen, nestif with the thresholds of .golangci.ymlyes
testgo build, go vet, make coverageyes
bddgo test ./... -run TestFeatures -vyes
integrationgo test -tags=integration ./... -race -count=1yes
mutation-fastgremlins on each internal/domain packageyes
mutationexhaustive gremlins (schedule and dispatch only)opens a harness:red issue on failure
driftdead code, go mod tidy -diff, knip, coverage-quality (schedule and dispatch only)advisory
api-lintspectral on OpenAPI and AsyncAPIyes
vulngovulncheckyes
helm-lintct lint --charts charts/delivery-promise (pull requests only)yes
chart-testsevery charts/delivery-promise/tests/*.sh and test_*.py; a test that prints SKIP failsyes
arch-testgo test ./internal/architecture/... -vyes
weblint, tests and build of web/yes
docker-publishimage build and push (push to main; needs lint, complexity, test, bdd, integration, mutation-fast, vuln, api-lint, arch-test)release gate
releasepackages delivery-promise-<version>.tgz (push to main)release

The documentation site has its own workflow, .github/workflows/docs.yml (build on pull request, deploy on push to main).