Httput
httput package provide a tool suite to make an unitaries tests arround http and echo framework.
Requirements
Golang 1.12.4 or higher
download the package
go get -u github.com/ymohl-cl/gopkg/httput
Usage
import "github.com/ymohl-cl/gopkg/httput"
func main() {
// build a request
request := httptest.NewRequest(...)
// build a fake echo context
c := httput.NewContext(request)
// the call your handlers to test them
_ = MyHandler(c)
// finally print the response content
fmt.Printf("status code: %d", c.Rec.Code)
fmt.Printf("content body: %s", c.Rec.Body.String())
}
Output:
> "status code: 200"
> "content body: {\"status\":\"200\"}"
Changelog
v0.0.1
Initial commit
- fake echo context to tests handlers
- tests and documentation