HTTP testing made easy for layered Web applications in Go.
Non-trivial applications should be layered.
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
Make a custom build of protogo:
$ protogo build --plugin=github.com/protogodev/httptest
Or build from a local fork:
$ protogo build --plugin=github.com/protogodev/httptest=../my-fork
Usage
$ protogo httptest -h
Usage: protogo httptest --mode=STRING --spec=STRING <source-file> <interface-name>
Arguments:
<source-file> source-file
<interface-name> 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 "./<srcPkgName>_<mode>_test.go")
--fmt whether to make the test code formatted
See examples/usersvc.
Check out the Godoc.