moby/moby
Testing
Moby has two active suites and one frozen one. The full policy is in TESTING.md.
Suites
| Suite | Path | Status | What it covers |
|---|---|---|---|
| Unit | next to source files (*_test.go) |
Active | Functions, types, small integrations within a package. |
| API integration | integration/ |
Active | HTTP requests against a real daemon; checks state and replies. |
| Legacy integration-cli | integration-cli/ |
Frozen | Original CLI-driven E2E tests. No new tests accepted. |
Tests use gotest.tools/v3/assert for assertions and gotest.tools/v3/skip for environment guards.
Run them
make test-unit # unit only
make test-integration # API integration suite (uses dockerd-in-docker)
make test # unit + integration + docker-py
make test-docker-py # Python SDK conformanceScope examples:
TESTDIRS=./daemon/... TESTFLAGS='-run TestKill' make test-unit
TEST_INTEGRATION_DIR=./integration/container make test-integration
TEST_FILTER=TestContainerCreate make test-integrationhack/test/unit and hack/make.sh test-integration do the actual work; make just wraps them with the dev container. You can run them directly inside make shell.
Writing tests
- Unit tests live in the same package. Prefer accepting unexported interfaces in production code so fakes can be supplied in tests; this is called out in
TESTING.md. - New endpoint? Add a happy-path test in
integration/<area>/. - New error case? Cover it with a unit test. Don't add a separate integration test per error path.
- Use
skip.If(t, testEnv.IsRemoteDaemon(), "...")(and similar predicates fromtestutil/environment) so tests run only where they make sense.
Test environment
integration/ tests bring up a real dockerd and talk to it via the client module. The testutil/environment helpers expose predicates such as IsRemoteDaemon, IsLocalDaemon, IsRootless, and DaemonInfo(). See internal/testutil/.
Flaky tests
make test-integration-flaky runs each newly added integration test repeatedly, helping catch flakes before merge. The validate-pr.yml workflow exposes this.
Coverage
TESTCOVERAGE=1 make test-unit writes coverage profiles into bundles/. The CI uploads coverage to Codecov; config lives in .codecov.yml.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.