forked fromivpusic/httpcheck
- Notifications
You must be signed in to change notification settings - Fork3
supertest inspired library for testing HTTP servers
License
NotificationsYou must be signed in to change notification settings
ikawaha/httpcheck
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
supertest inspired library for testing HTTP servers.
A Fork fromivpusic/httpcheck with following changes:
- Change to set testing.T when generating the request instead of the constructor,
- Fix to prevent incorrect method chain,
- Add to the timeout option of the client to the checker.
go get github.com/ikawaha/httpcheckpackage mainimport ("github.com/ikawaha/httpcheck")funcTestExample(t*testing.T) {// testHandler should be instance of http.Handlerchecker:=httpcheck.New(&testHandler{})checker.Test(t,"GET","/some/url").WithHeader("key","value").WithCookie("key","value").Check().HasStatus(200).HasCookie("key","expectedValue").HasHeader("key","expectedValue").HasJSON(&someType{})}
package mainimport ("github.com/ivpusic/httpcheck")funcTestExample(t*testing.T) {checker:=httpcheck.New(&testHandler{})checker.Test(t,"GET","/some/url").WithString("Hello!")Check().HasStatus(200)}
package mainimport ("github.com/ivpusic/httpcheck")funcTestExample(t*testing.T) {checker:=httpcheck.New(&testHandler{})data:=&someStruct{field1:"hi",}checker.Test(t,"GET","/some/url").WithJSON(data)Check().HasStatus(200)}
package mainimport ("github.com/ivpusic/httpcheck")funcTestExample(t*testing.T) {checker:=httpcheck.New(&testHandler{})data:=&someStruct{field1:"hi",}checker.Test(t,"GET","/some/url").WithXML(data)Check().HasStatus(200)}
package mainimport ("net/http""github.com/ivpusic/httpcheck")funcTestExample(t*testing.T) {checker:=httpcheck.New(&testHandler{})checker.TestRequest(t,&http.Request{/* fields */ }).Check().HasStatus(200)}
package mainimport ("net/http""github.com/ikawaha/httpcheck")funcTestExample(t*testing.T) {checker:=httpcheck.New(&testHandler{})checker.Test(t,"GET","/some/url").Check().HasStatus(200).HasBody([]byte("some body")).Cb(func(response*http.Response) {/* do something */ })}
License MIT
About
supertest inspired library for testing HTTP servers
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Languages
- Go100.0%