Go interfaces make test stubbing easy
Aug 27, 2014John Graham-Cumming

Summary
This post introduces the use of Go interfaces to simplify unit testing for components like image compression workers. By defining a `Job` interface, the `Worker` package can accept any type that implements `Do()` and `Priority()`, allowing for the creation of `DummyJob` implementations for testing purposes. This significantly improves test isolation and reduces the complexity of setting up test environments for components that interact with complex underlying systems.
More from the Data Infrastructure & Analytics trail
- Introducing Cloudflare Basin: an open, serverless data platform, now generally available
- Introducing the Billable Usage API: programmatic cost visibility for Cloudflare
- Announcing the Monetization Gateway: charge for any resource behind Cloudflare via x402
- How we built Cloudflare's data platform and an AI agent on top of it
- Iran's Internet is partially restored, Cloudflare Radar data shows