https://github.com/timothystiles/ditto
A Go package for mockless 3rd party API testing.
https://github.com/timothystiles/ditto
go golang mock testing
Last synced: 9 months ago
JSON representation
A Go package for mockless 3rd party API testing.
- Host: GitHub
- URL: https://github.com/timothystiles/ditto
- Owner: TimothyStiles
- License: mit
- Created: 2024-01-09T03:57:49.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-20T17:24:26.000Z (over 2 years ago)
- Last Synced: 2025-02-02T18:33:23.062Z (over 1 year ago)
- Topics: go, golang, mock, testing
- Language: Go
- Homepage: https://pkg.go.dev/github.com/TimothyStiles/ditto
- Size: 43 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ditto
Ditto is a dead simple code-gen free, mock free, CLI tool free, API call caching package for testing 3rd party APIs in Go.
You shouldn't have to mock 3rd party APIs to test your code. Ditto caches API responses for you to use in your tests.
All you have to do is replace your API client's `http.Client` with `ditto.Client` when writing your tests and you're good to go. Ditto checks if the request has been made before and if so, returns the cached response. If not, it makes the request and caches the response for you to run your tests against later on.
## Install
```bash
go get github.com/TimothyStiles/ditto
```
## Usage
https://github.com/TimothyStiles/ditto/blob/da8d0f083d92b16aa99029b9dfbc8edb862bbf5b/example_test.go#L11-L24