Created
February 8, 2014 20:36
-
-
Save cgarvis/8889900 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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