Examples
Complete example projects in the apitest repository, and the tested examples behind these docs.
Example projects
The examples directory of the apitest repository has complete, runnable projects.
| Example | Shows |
|---|---|
| gin | A gin application. |
| echo | An echo application. |
| fiber | A fiber application, adapted to net/http. |
| gorilla | The gorilla web toolkit. |
| httprouter | julienschmidt/httprouter. |
| iris | An iris application. |
| graphql | A gqlgen GraphQL server. |
| ginkgo | Tests written as Ginkgo specs. |
| mocks | Mocking outbound calls, including a custom matcher. |
| websockets | A websocket handler under test. |
| sequence-diagrams | Generating sequence diagrams. |
| sqlite, mysql, postgres | Database queries in sequence diagrams. |
Live reports
Reports generated by the examples on this site:
User API
A request with two mocked dependencies.
Database
SQL queries recorded with x/db.
Custom events
A message published to a queue.
Unmatched mock
A call that matched no mock, flagged in the report.
The examples behind these docs
Every code sample on this site is included from a Go module of tests that run against the latest apitest release. The samples are therefore real, compiling code, and each one passes.