Skip to main content

Testing

Counts below were taken from the tree on this branch: 152 *_test.go files, of which 40 carry the integration build tag; 27 Gherkin files with 172 scenario definitions under features/ (249 scenarios executed once every Examples row of a Scenario Outline is counted), plus 1 MCP feature file with 9 scenarios (definitions counted by Scenario and Scenario Outline; executed counts are the N scenarios line of go test . -run TestFeatures -count=1 -v).

Source: Makefile, .github/workflows/ci.yml, .gremlins.yaml, features/, internal/architecture/.

Make targets​

make help prints the list. Every target mirrors a CI job.

TargetRunsNeeds
make build / make vetgo build ./... / go vet ./...Go
make fmt / make fmt-checkgofmt -w . / fail on any unformatted fileGo
make lintgolangci-lint run ./... (CI pins v2.13.1)golangci-lint
make testgo test ./... -race — unit, httptest, both godog suites, MCP evals, fitness testsGo only (unit/BDD test doubles: the in-memory adapters never run in a binary)
make coveragemake test with -coverpkg=./internal/domain/...,./internal/application/... and the 90 % gateGo
make bddgo test ./... -run TestFeatures -v (the REST acceptance suite)Go
make arch-testgo test ./internal/architecture/... -vGo
make integrationgo test -tags=integration ./... -race -count=1Docker (testcontainers boots Postgres / Kafka per suite; no DATABASE_URL, no compose)
make contractscripts/contract-test.shpip install 'schemathesis==4.28.0'
make mutationgremlins unleash ./internal/domain/stockgremlins v0.6.0
make mutation-fullgremlins unleash ./internal/domain --workers 1 --timeout-coefficient 30gremlins v0.6.0
make vulngovulncheck ./...govulncheck
make checkfmt-check vet build lint test—
make check-allcheck + coverage arch-test bdd—
make check-fastfmt-check vet arch-test + tests of packages changed vs HEAD— (agent Stop hook)
make guide-lint / make harness-testscripts/harness/guide_lint.py / scripts/harness/test_hook.pyPython 3

Git hooks (lefthook.yml, after lefthook install): pre-commit runs make fmt-check, make vet, make lint; pre-push runs make check. Neither runs integration or mutation.

The layers​

Unit and handler tests​

Plain go test with the in-memory adapters (test doubles only; no binary links them, ADR 0042) and fixed clocks: aggregates and value objects in internal/domain/*, use cases in internal/application/usecases, the HTTP handlers through httptest (internal/adapters/inbound/http), Kafka consumers against fake readers, publishers' encoding (including the events/testdata/log_publisher_golden.json golden), and composition-root wiring in cmd/inventory/*_test.go and cmd/mcp/*_test.go. CI enforces 90 % statement coverage over the domain and application packages.

Acceptance (BDD)​

features_test.go runs every features/*.feature with godog against a fresh cmd/inventory router wired to the in-memory test doubles — a black-box test of the REST API (ADR 0007).

Feature fileScenario definitions
bin_registration.feature7
bin_validation.feature1
classification_rules.feature4
container_rules.feature5
containers.feature14
cycle_count.feature3
cycle_count_edges.feature2
demand_ref.feature4
fulfillment_rules.feature10
held_stock.feature4
inbound_receipt.feature1
order_pick_completion.feature3
product_classification.feature1
receive.feature1
relocation_rules.feature23
reservation.feature4
reservation_expiry.feature4
reservation_lines.feature4
storage_rules.feature22
stow.feature3
stow_placement.feature5
transfer_allocation.feature10
transfer_receipt.feature9
transfer_scan_edges.feature13
transfer_stow.feature13
transfer_stow_rules.feature1
usable_inventory.feature1
Total172 (249 executed)

The *_rules.feature files pin rules documented in docs/ddd/ (use cases, aggregate canvas, troubleshooting) one by one: relocation (#17-#20), storage (#1-#6, #9-#11), fulfillment (#12, #13), classification (#8), containers and transfer stow (#16). Step definitions for them are in features_rules_test.go (registered from features_test.go; the other suites live in the sibling features_*_test.go files). The BDD-only statement coverage over ./internal/... (go test . -run TestFeatures -count=1 -coverpkg=./internal/...) is 64.7 %.

MCP evals​

Three layers over cmd/mcp's server (ADR 0027), all in internal/adapters/inbound/mcp:

  • E1 schema and registry (eval_governance_test.go): input schemas resolve and constrain, every parameter is described, the registry matches testdata/tool_registry.golden (name, read-only, destructive), and tool names are unique against testdata/fleet_tool_snapshot.golden.
  • E2 wire conformance (eval_conformance_test.go): initialize handshake, unknown tool / resource / prompt rejected, wrong-typed and extra arguments rejected, resource template and prompt discovery, session close.
  • E3 behaviour (evalsuite_test.go): testdata/features/mcp_tools.feature (9 scenarios) through godog.

They run in make test and again, by name, in the evals-tests CI job.

Architecture fitness​

internal/architecture (ADR 0006, ADR 0029):

TestGuards
TestHexagonalArchitecturearch-go layering: domain imports nothing internal; application only domain; inbound and outbound adapters never import each other; nothing imports cmd; ports holds only interfaces; the analytics region is isolated.
TestMCPAdapterDependencyRuleThe MCP adapter depends only on the application and domain layers, and nothing else imports it (ADR 0008).
TestNoAuthMiddlewareReintroducedNo auth middleware on REST or MCP (the fleet is unauthenticated).
TestKafkaConsumerGroupNeverHardcodedInlineConsumer group ids are named constants or configuration.
TestKafkaIntegrationTestsUseTestcontainers (+ detector test)Kafka integration tests boot their own broker (checked per file).
TestPostgresIntegrationTestsUseTestcontainers (+ detector test)Postgres integration tests boot their own database (checked per package).
TestEventCatalogueMatchesContract (+ detector test)The event catalogue in code matches the messages declared in apis/asyncapi.yaml.
TestCloudEventsOnlyNo EVENT_ENVELOPE_MODE toggle anywhere, and a module that talks to Kafka imports the CloudEvents SDK.
TestReplayConsumersSetCommitIntervalA kafka-go reader on a process-unique group (the facility cache's full replay) sets CommitInterval.
TestDomainHasNoWireStructTags (+ detector test)No json: / db: tags on domain types.
TestRuntimeBinaryHasNoInMemoryAdapters (+ TestRuntimeBinarySensorBites, TestRuntimeBinarySensorCoversEveryCmd, runtime_no_memory_fitness_test.go)No non-test file under cmd/** imports internal/adapters/outbound/memory: Postgres and Kafka are the only runtime (ADR 0042). The twins prove the sensor flags a bad fixture and that it covers every cmd/ directory.
TestOutboxRelaysPassAttemptCap (+ TestOutboxRelayCapSensorFailsOnBadFixtures)Every non-test NewOutboxRelay call under cmd/ passes WithMaxAttempts (ADR 0038), so one poison row cannot block the relay forever.
TestMCPOptionalToolInputsCarryOmitempty (+ TestMCPOptionalToolInputsSensorFailsOnBadFixtures)An MCP tool input field whose jsonschema description says "optional" carries omitempty, or the SDK advertises it as required and calls without it fail (gap fix D16).
TestKafkaWritersSetRequiredAcks (+ TestKafkaWriterAcksSensorBites)Every kafka-go Writer composite literal in a non-test file under internal/ or cmd/ sets RequiredAcks (the import alias is resolved per file). kafka-go defaults it to RequireNone (acks=0): the broker never confirms the write, so a broker blip silently drops the message while WriteMessages returns nil. The twin proves the sensor flags a bad fixture under any alias.
TestDeadLetterCallsGuardCancellation (+ TestDeadLetterShutdownSensorBites, kafka_dlq_shutdown_fitness_test.go)Every function in a non-test file under internal/adapters/inbound/kafka that sends to the dead-letter topic must reference ctx.Err() (any context-named value) or context.Canceled in its own body, or carry a //dlq:deterministic <reason> comment on the call line or the line above it. A handler that fails because the process is stopping must not dead-letter a good message and commit past it (network-fulfillment #89); a guard in the caller does not count. The sensor test proves the detector flags the pre-fix shape.
TestKafkaWriterTopicNotSetTwice (+ TestKafkaWriterTopicSensorBites, kafka_writer_topic_fitness_test.go)kafka-go rejects every write whose Message.Topic is set when the Writer also has a Topic. Per Go package under internal/ and cmd/: once any kafka-go Message literal sets Topic, every Writer literal in that package must leave Topic empty, unless it carries //kafka:fixed-topic-writer <reason> and no Topic-setting Message is provably written through it. Writers configured after construction and WriterConfig are not covered. (Escape: warehouse-planning's domain DLQ writer, where no dead letter ever landed.)

Integration (testcontainers)​

44 *_integration_test.go files behind //go:build integration. Each suite starts its own postgres and/or Kafka container (internal/testsupport/kafkatc waits for the group coordinator before tests run). Covered: every Postgres repository, migrations, optimistic concurrency, the idempotency middleware (including lineNo), the outbox publisher and relay (including the attempt cap: a poison row, then a good row that publishes, and the re-arm SQL, outbox_relay_cap_integration_test.go), the sweeper, pool limits, rehydration, the transfer, confirm-pick, inbound receipt and product-master hand-overs at the use-case level, the analytics store, the facility cache consumer, publisher partitioning, the MCP Streamable-HTTP transport, the cmd/inventory housekeeping wiring, TestRunOnRealPostgresAndKafka (boots run(ctx) on real Postgres and Kafka, cmd/inventory/e2e_integration_test.go) and cmd/mcp outbox wiring. CI runs the whole tree (go test -tags=integration ./... -race -count=1) with TESTCONTAINERS_RYUK_DISABLED=true.

Contract​

scripts/contract-test.sh builds cmd/inventory, starts it on 127.0.0.1:18080 (CONTRACT_PORT) against the Postgres named by DATABASE_URL and the Kafka broker named by KAFKA_BROKERS (the script refuses to start without them; CI provides a postgres:16 and a confluentinc/confluent-local service container, locally start disposable ones as the script header shows), waits for /readyz, and runs st run apis/openapi.yaml with up to 100 examples per operation (CONTRACT_MAX_EXAMPLES) and 4 workers, with the hooks in scripts/contract_hooks.py (a fresh UUID Idempotency-Key per request) and --generation-allow-x00 false (a NUL byte is answered with a client error before any other middleware, internal/adapters/inbound/http/nul.go). Excluded (--exclude-operation-id / --exclude-tag, scripts/contract-test.sh:137-140): the Reports tag (served by cmd/inventory-reports) and the operations stageTransferReceipt, stowTransferStock (a well-formed scan with no ledger row is quarantined with 422 by design) and relocateStock (a well-formed body with fromBin == toBin is refused with 422 same-bin), because Schemathesis' positive-data-acceptance check cannot model "valid shape, refused by domain state"; the unit, integration and BDD suites pin them instead. classifyProduct left the spec at stage E, so no exclusion remains for it.

Mutation​

gremlins v0.6.0 with .gremlins.yaml: 1 worker, timeout coefficient 30, and thresholds efficacy 99 and mutant-coverage 99 (gremlins fails at or below the threshold, so a single surviving mutant fails the run). The fast subset ./internal/domain/stock blocks every PR (mutation-fast); the whole ./internal/domain runs weekly (mutation).

Frontend and chart​

web/ (the inventory micro-frontend) has its own Vitest suite (npm test), oxlint and tsc -b, run by the web job. The chart has two tests, both run by the chart-tests CI job: charts/inventory-storage/tests/render_test.sh (the API Deployment mounts the env ConfigMap with envFrom, tuned config.* values reach it, the other workloads do not mount it) and charts/inventory-storage/tests/test_service_selectors.py (each Service selects exactly one Deployment). Run them locally with bash charts/inventory-storage/tests/render_test.sh and python3 charts/inventory-storage/tests/test_service_selectors.py.

CI jobs​

.github/workflows/ci.yml runs on push and pull request to main and develop, weekly (Monday 06:00 UTC) and on dispatch.

JobRunsWhen
lintgolangci-lint v2.13.1always
guide-lintguide_lint.py, repo_lint.py, test_hook.py, test_repo_lint.pyalways
complexitygolangci-lint with gocyclo,gocognit,cyclop,funlen,nestif; informational gocyclo > 10 reportalways
testbuild, vet, then make coverage (go test ./... -race with the Makefile's coverage scope and 90 % gate)always
bddgo test ./... -run TestFeatures -valways
contractscripts/contract-test.shalways
evals-testsgo test ./internal/adapters/inbound/mcp/... -race -run '^TestEval|^TestMCPEvalSuite' -valways
integrationgo test -tags=integration ./... -race -count=1always
mutation-fastgremlins unleash ./internal/domain/stockalways
mutationgremlins unleash ./internal/domainschedule / dispatch only
driftdeadcode, go mod tidy -diff, knip on web/, coverage-quality reportschedule / dispatch only
api-lintSpectral on apis/openapi.yaml and apis/asyncapi.yamlalways
vulngovulncheck v1.1.4always
docs-api-driftnpm run clean-api-docs inventory && npm run gen-api-docs inventory, then git diff --exit-code -- docs/api-reference/restalways
helm-lintct lint --charts charts/inventory-storagepull requests
chart-testsbash charts/inventory-storage/tests/render_test.sh (ConfigMap envFrom mount, config values) and python3 charts/inventory-storage/tests/test_service_selectors.py (with PyYAML pinned)always
arch-testgo test ./internal/architecture/... -valways
webbuilds warehouse-ui-kit develop, then lint, tsc -b, test, build of web/always
trivy-scanimage build + Trivy, blocking on fixable CRITICAL/HIGHpull requests
docker-publishpush, cosign sign, SBOM attest to ghcr.io/iqvo/inventory-storagepush to main
releasenext vX.Y.Z tag, Helm chart to oci://ghcr.io/iqvo, GitHub releasepush to main

.github/workflows/docs.yml builds this site (npm ci && npm run build in docs/) on pull requests that touch docs/** or apis/**, and builds and deploys it to GitHub Pages on push to main.

Running a single layer locally​

go test ./internal/domain/... -race # one package
go test -run TestFeatures -v . # REST acceptance suite only
go test -tags=integration ./internal/adapters/outbound/postgres/... -race -count=1
go test ./internal/adapters/inbound/mcp/... -run '^TestEval|^TestMCPEvalSuite' -v
CONTRACT_MAX_EXAMPLES=20 ./scripts/contract-test.sh