An open API service indexing awesome lists of open source software.

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.

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].

![layered-app](layered-app.png)

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