Skip to content

Instantly share code, notes, and snippets.

@cgarvis
Created February 8, 2014 20:36
Show Gist options
  • Save cgarvis/8889900 to your computer and use it in GitHub Desktop.
Save cgarvis/8889900 to your computer and use it in GitHub Desktop.
package main
import(
"net/http"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
type ResponseTester struct {
response *http.Response
}
func (rt ResponseTester) json() {
Convey("content type is json", func() {
So(rt.response.Header.Get("Content-Type"), ShouldEqual, "application/json")
})
}
func (rt ResponseTester) status(code int) {
Convey(fmt.Sprintf("status code is %d", code), func() {
So(rt.response.StatusCode, ShouldEqual, code)
})
}
func TestRestAPI(t *testing.T) {
Convey("REST API", t, func() {
response, _ := http.Get("http://localhost:3000/users")
resp := ResponseTester{resp}
resp.json()
resp.status(200)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment