https://github.com/protogodev/httptest
HTTP testing made easy for layered Web applications in Go.
https://github.com/protogodev/httptest
Last synced: 5 months ago
JSON representation
HTTP testing made easy for layered Web applications in Go.
- Host: GitHub
- URL: https://github.com/protogodev/httptest
- Owner: protogodev
- License: mit
- Created: 2022-06-11T14:50:48.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-13T09:40:34.000Z (about 4 years ago)
- Last Synced: 2024-06-21T16:56:49.042Z (about 2 years ago)
- Language: Go
- Homepage: https://pkg.go.dev/github.com/protogodev/httptest
- Size: 51.8 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httptest
HTTP testing made easy for layered Web applications in Go.
## Layered Web Applications
Non-trivial applications should be [layered][1].

For layered Web applications:
- HTTP Server/Client should be separated from Service (i.e. the business rules)
- HTTP Server should call an interface implemented by Service
- HTTP Client should implement an interface defined in Service
## Installation
Make a custom build of [protogo](https://github.com/protogodev/protogo):
```bash
$ protogo build --plugin=github.com/protogodev/httptest
```
Or build from a local fork:
```bash
$ protogo build --plugin=github.com/protogodev/httptest=../my-fork
```
Usage
```bash
$ protogo httptest -h
Usage: protogo httptest --mode=STRING --spec=STRING
Arguments:
source-file
interface-name
Flags:
-h, --help Show context-sensitive help.
--mode=STRING generation mode (server or client)
--spec=STRING the test specification in YAML
--out=STRING output filename (default "./__test.go")
--fmt whether to make the test code formatted
```
## Examples
See [examples/usersvc](examples/usersvc).
## Documentation
Check out the [Godoc][2].
## License
[MIT](LICENSE)
[1]: https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
[2]: https://pkg.go.dev/github.com/protogodev/httptest