Skip to main content

Testing

The test pyramid of offer-availability as it is in the repository: unit tests per layer, 233 godog scenarios (190 definitions), a shared repository contract, testcontainers integration tests, architecture fitness tests and mutation testing on the domain. Docker is needed only for make integration; every other target runs offline.

The pyramid​

LevelWhereWhat it provesRuns in
Unit, domaininternal/domain/{catalog,feed,listing,nodestatus,shared,shared/gs1} (*_test.go)Aggregate invariants, state machines, GTIN and SSCC check digits, snapshotsmake test
Unit, applicationinternal/application/usecases/*_test.goEvery use case over the in-memory adapters: events raised, ordering, outcomesmake test
Unit, adaptersinternal/adapters/inbound/http (handlers, idempotency middleware, telemetry), inbound/mcp, inbound/a2a, inbound/kafka (consumer, tracing), inbound/requestlog, outbound/kafka (encoder, writer, relay sink, health), outbound/outbox, outbound/telemetry, outbound/postgres (outbox trace), kafka/cloudevents, bootretry, cmd/* (config, telemetry, routers)Wire contracts, status codes, problem slugs, CloudEvents envelope, retriesmake test
Acceptance (godog / Gherkin)features/*.feature + features/*_test.goEnd-to-end behaviour through the REST handlers over in-memory adaptersmake bdd, and inside make test
Repository contractinternal/adapters/outbound/repocontractOne behavioural suite that both the in-memory adapter (memory_test.go) and the Postgres adapter (postgres_integration_test.go) must passmake test, make integration
Integration (testcontainers)files tagged //go:build integration: cmd/api/e2e_integration_test.go, cmd/api/main_integration_test.go, cmd/mcp/main_integration_test.go, cmd/a2a/main_integration_test.go, internal/adapters/inbound/http/idempotency_integration_test.go, internal/adapters/inbound/http/idempotency_replay_integration_test.go, internal/adapters/outbound/outbox/relay_integration_test.go, internal/adapters/outbound/postgres/{postgres,outbox,outbox_trace}_integration_test.goReal Postgres and Kafka: repositories, outbox drain and trace propagation, the relay, the idempotency middleware, the real-wiring boot and the consumer flowmake integration
Contract against the specsinternal/architecture/catalogue_fitness_test.go (TestEventCatalogueMatchesContract), internal/adapters/inbound/mcp/governance_test.go (TestToolRegistryGolden) and the Spectral lint of apis/*.yaml in CIThe event catalogue matches apis/asyncapi.yaml; the MCP tool registry matches its golden filemake arch-test, make test, CI api-lint
Fitness (architecture)internal/architecture/*_test.go, 14 filesLayering and runtime rules, see belowmake arch-test
Mutation.gremlins.yaml, gremlins v0.6.0 on internal/domainThe domain tests assert rather than merely executemake mutation, make mutation-full, CI

Nine of the *_test.go files carry the integration build tag; everything else runs in make test.

Acceptance features​

Fourteen feature files, 190 scenario definitions (git grep -c -E "^[[:space:]]*Scenario" -- features) that the runner executes as 233 scenarios because the Examples rows of the Scenario Outlines expand (the 233 scenarios (233 passed) line of go test ./features -run TestFeatures -count=1 -v). They are run by features/features_test.go (TestFeatures, Strict: true) against the REST handlers wired to the in-memory adapters (features/world_test.go); no database or broker is needed.

FileDefinitionsCovers
features/suppression_rules.feature33SuppressOnNodeUnavailable and the owner cause (ADR 0013): precedence DISCONTINUED > NODE_NOT_SELLABLE > OWNER_SUSPENDED, seller and node view ordering
features/received_stock_rules.feature31Received seller stock creates owner listings (ADR 0013 rule 8, ADR 0014): item resolution by id or GTIN, skip counters, inbox idempotency, suppression reason at creation
features/feed_rules.feature28InventoryFeed and FullFeedZeroing: high-water mark per node, stale lines, quantity and line bounds, first offending line, full-feed edges, event data
features/http_api.feature19Routes, status codes, problem slugs, pagination, probes-level wire behaviour
features/http_rules.feature19The use-case error rows through the real router: discontinue twice, FAILED and SUPERSEDED feeds, bounds, owner in the JSON views
features/inventory_feeds.feature10Partial and full feeds, stale lines, supersede, FAILED and re-send, counters
features/packaging.feature10GTINs, pack levels, immutability of unitsPerPack, retire, ordering
features/catalog_rules.feature9CatalogItem bounds (dimension, weight, title), validation order, CatalogItemCreated fields, discontinuing
features/node_status.feature8Node events suppressing and restoring listings, older events ignored
features/listings.feature5Listing creation, duplicate pair, suppression at creation
features/idempotency.feature5Replay, key reuse, missing key
internal/adapters/inbound/http/idempotency_replay_classes_test.go (+ replay_class_test.go)20+The fleet replay-class suite over the real middleware (no Docker), the class of every problem type, the ADR 0016 table held equal to the catalogue
features/returns_restock_rules.feature5Return completions restock owner listings (ADR 0015)
features/catalog.feature4Item creation, discontinuation cascade
features/ownerref.feature4Seller-owned listings next to the operator-owned one

Make targets​

TargetWhat it runs
make checkfmt-check, vet, build, lint (golangci-lint, --allow-parallel-runners), test (go test ./... -race). The pre-commit and pre-push gate.
make check-allcheck plus coverage, arch-test, bdd; run before pushing a change that touches Go code
make check-fastfmt-check, vet, arch-test and the tests of the packages changed against HEAD (the agent Stop hook)
make testgo test ./... -race
make coveragego test ./... -race -coverprofile with -coverpkg=./internal/domain/...,./internal/application/... and a 90 % gate
make bddgo test ./... -run TestFeatures -v
make arch-testgo test ./internal/architecture/... -v
make integrationgo test -tags=integration ./... -race -count=1; Docker only, each test boots its own Postgres or Kafka via testcontainers (no DATABASE_URL, no compose file, no t.Skip gate)
make mutationgremlins on each ./internal/domain/*/ package
make mutation-fullgremlins on ./internal/domain, one worker, timeout coefficient 30 (the scheduled run)
make vulngovulncheck ./...
make guide-lint, make harness-testLint the agent guides; unit-test the agent hooks

.gremlins.yaml sets one worker, timeout coefficient 30, an efficacy threshold of 98 and a mutant-coverage threshold of 99 as plain integers (gremlins fails at or below the threshold, and ignores a quoted string). Measured on 2026-11-15: catalog 94 killed and 1 lived of 95 (an equivalent mutant, see MUTATION.md), feed 67/67, listing 56/56, nodestatus 15/15, sellerstatus 8/8, shared 187/187.

Fitness tests (internal/architecture)​

TestRule
TestHexagonalArchitectureDomain imports nothing of the application or adapters; the application imports no adapter; inbound and outbound adapters never import each other
TestMCPAdapterDependencyRule, TestMCPOptionalToolInputsCarryOmitemptyThe MCP adapter depends on the read use cases only; optional tool inputs carry omitempty
TestA2AAdapterDependencyRule, TestA2AAdapterIsReadOnly, TestA2ABinaryIsReadOnlyAndKafkaFree, TestNoOutboundA2AClient, TestA2ASDKOnlyInTheA2AAdapterAndBinaryA2A is read-only, cmd/a2a never touches Kafka, no outbound A2A client exists, the SDK stays in its adapter
TestNoAuthMiddlewareReintroducedNo authentication middleware reappears
TestRuntimeBinaryHasNoInMemoryAdapters, TestRuntimeBinaryDoesNotImportTheRepositoryContractcmd/** never imports the memory adapter or the repository contract: no in-memory runtime
TestCloudEventsOnly, TestNoEventEnvelopeToggleOrFlatEnvelope, TestEventCatalogueMatchesContractCloudEvents on every message; no flat or toggled envelope; the catalogue equals apis/asyncapi.yaml
TestKafkaConsumerGroupNeverHardcodedInlineThe consumer group comes from the environment, never a literal
TestReplayConsumersSetCommitIntervalFull-replay consumers (unique group per process) set a commit interval
TestKafkaWritersSetRequiredAcks, TestKafkaWriterTopicNotSetTwice, TestDeadLetterCallsGuardCancellationWriters set acks, never set the topic twice, dead-letter calls guard cancellation
TestOutboxRelaysPassAttemptCapEvery relay passes the attempt cap
TestKafkaIntegrationTestsUseTestcontainers, TestPostgresIntegrationTestsUseTestcontainersIntegration tests boot their own containers
TestNoGoFilesAtRepoRootNo Go file at the repository root

Several ...SensorBites / ...SensorFailsOnBadFixtures tests prove each sensor fails on a deliberately bad fixture.

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

Triggers: push to main and develop, pull requests to both, a weekly schedule (Monday 06:00 UTC) and manual dispatch.

JobWhenWhat
lintalwaysgolangci-lint v2.14.0
guide-lintalways, advisoryscripts/harness/guide_lint.py, test_hook.py
complexityalwaysgocyclo, cyclop, gocognit, nestif, funlen (gate 15)
testalwaysbuild, vet and make coverage (90 % gate)
bddalwaysgo test ./... -run TestFeatures -v
integrationalwaysgo test -tags=integration ./... -race -count=1
mutation-fastalwaysgremlins on every domain package
mutationschedule and manualexhaustive gremlins on ./internal/domain; opens or closes the harness:red issue
driftschedule and manualdead code, unused go.mod entries, unused frontend exports, coverage quality
api-lintalwaysSpectral on apis/openapi.yaml and apis/asyncapi.yaml
vulnalwaysgovulncheck
helm-lintpull requestsct lint and the Service-selector test
chart-testsalwayscharts/offer-availability/tests
arch-testalwaysgo test ./internal/architecture/... -v
webalwaysthe console remote (web/): lint, tsc -b, tests, build
docker-publishpush to mainbuild, push, sign and attest the image
releasepush to maintag the image, package and push the chart, create the release

The documentation site has its own workflow, .github/workflows/docs.yml (build on pull requests, deploy on push to main). To check it locally run npm ci, npx tsc --noEmit -p . and npm run build in docs/.

Running one thing​

go test ./internal/domain/feed/... -race # one package
go test ./features/... -run 'TestFeatures' -v # all scenarios
go test -tags=integration ./cmd/api/... -race -count=1 # the real-wiring test (Docker)