Integration¶
Four integration patterns: service-layer port mocking with testify/mock, JSON format verification and round-trip testing, struct-based fixture setup/teardown for isolated test state, and embedded infrastructure testing with in-memory Redis using miniredis.
Chapters¶
- chapter-27-service-layer-mocked-ports.md — Service Layer with Mocked Ports — mock repository and email interfaces to test business logic in isolation
Source:chapters/chapter-27-service-layer-mocked-ports/ - chapter-28-json-format-verification.md — JSON Format Verification —
assert.JSONEq,json.MarshalIndent, and round-trip serialization tests
Source:chapters/chapter-28-json-format-verification/ - chapter-29-setup-teardown-fixtures.md — Setup/Teardown Fixtures — struct-based fixtures with Setup/Teardown for isolated, repeatable test state
Source:chapters/chapter-29-setup-teardown-fixtures/ - chapter-34-embedded-infrastructure.md — Embedded Infrastructure Testing — use in-memory replacements like
miniredis.RunT(t)for realistic protocol coverage without external processes
Source:chapters/chapter-34-embedded-infrastructure/
Running the code¶
Each chapter is a standalone Go module. To run tests for a chapter: