Functional tests and benign failures
Worked example
This is an offline lesson. Data are fictional and Docker commands are unexecuted. Any optional execution requires an authorized disposable VM, a verified context, synthetic data, restricted access and no external transmission. Do not collect secrets or private output. Before any separately authorized Docker query, verify the effective endpoint and builder (including environment overrides), not just the context name. Use only disposable lab resources; a failed check is a stop condition, not permission to retry against a different host.
Local test command in project/reference:python -B test_project.pyExpected tests: empty list, authenticated write, invalid token,invalid payload, proxy read, proxy write denied, backend unavailable,SQLite backup integrity and isolated restore.Container tests: staged only; use RUNBOOK.md and EVIDENCE.md.Record pass/fail/blocked rather than inferred success.Local tests use temporary databases and localhost HTTP servers on ephemeral ports, not a Docker engine. They verify HTTP status and JSON content, including 401 for a wrong token, 400 for malformed content and 405 for a proxy write. A proxy dependency failure should produce 502 rather than a misleading success. The test verifies a fresh SQLite snapshot against the expected records. The same source can still fail in Docker due to image architecture, UID, volume ownership, network policy or secret mount mode. Separate source tests, Compose parsing, actual build, actual run and post-start verification. Use observed status codes and bounded timeouts instead of guessing at logs. The supplied 14-test suite already contains missing-token and overlong-note cases. Extend it with an authorized request carrying an unexpected JSON field, asserting HTTP 400 and unchanged database rows. A local negative test is evidence only for that input and process, not proof of container isolation or general security.
Common mistake
A successful local test must not be reported as a successful Docker integration test.
Manual practice
Run the source tests, then add a test for an unexpected JSON field with a valid synthetic token. Assert 400 and unchanged rows, then verify a valid write succeeds as a positive control. Design a separate container acceptance test for replacement persistence.
Worksheet: lab-fixtures/docker-professional-capstone/04-tests/scenario.txt. Project: lab-fixtures/docker-professional-capstone/project/.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Functional tests and benign failures — Knowledge check
Interpret capstone evidence and make a safe operational decision.
For the specific API request in the local negative test, what does HTTP 401 establish?
What should the proxy return when its backend is unavailable?
Can source tests establish volume ownership?