This workshop will cover:
Reading, writing and debugging basic Go code*
Writing tests:
writing unit tests, integration tests: dependency injection, mocking
API mocking with basic standard lib Go tools
specific Go packages like gomock, testcontainers, dockertest (with examples of reading code from OSS projects)
software design for testability (identifying where to decouple and extract interfaces)
* advanced features of the language will not be covered at length and this will be conveyed
The workshop will include a git repository which upon cloning will include 3 "Labs", each of which would have codebases with bugs which we'd first identify, fix and then write tests to cover.
Lab 1:
A faulty quick-commerce API which shall panic due to some basic missing handling in the endpoints. We'll figure out the RCAs looking at the logs and/or using a debugger. After that we'll write tests using the standard Go testing package.
Surge pricing logic is broken and tightly coupled to a real-time Weather API. Fixing this will introduce Dependency Injection to mock the API..
Lab 2:
A faulty streaming music activity analysis microservice with similar bugs (as a way for the audience to do it by themselves first now). Introduces table-driven testing.
Lab 3:
A faulty tickets-booking API which relies on the db and redis. We'll cover gomock to automatically generate mocks for large interfaces.,testcontainers to spin up ephemeral Docker containers (like Postgres and Redis) for true integration testing. Showcase how it runs in CI and so on.
Target Audience: Students and developers with basic programming knowledge in any language. No prior Go experience is required though it would be beneficial.
Read and debug Go, work on unfamiliar codebases, using the debugger, interpret panic stack traces
Refactoring Go code for testability, using Dependency Injection and Interfaces to decouple business logic from external systems like APIs or databases.
Writing tests, implement standard Go testing patterns, including Table-Driven Tests.
Learn about production testing tooling