Update tests

This commit is contained in:
Brendan Burns
2014-06-09 07:16:43 -07:00
parent 0b6702e80b
commit 9010ef954c
4 changed files with 191 additions and 2 deletions

View File

@@ -19,9 +19,14 @@ import (
"io/ioutil"
"log"
"net/http"
"testing"
)
// TestInterface is a simple interface providing Errorf, to make injection for
// testing easier (insert 'yo dawg' meme here)
type TestInterface interface {
Errorf(format string, args ...interface{})
}
// FakeHandler is to assist in testing HTTP requests.
type FakeHandler struct {
RequestReceived *http.Request
@@ -41,7 +46,7 @@ func (f *FakeHandler) ServeHTTP(response http.ResponseWriter, request *http.Requ
f.ResponseBody = string(bodyReceived)
}
func (f FakeHandler) ValidateRequest(t *testing.T, expectedPath, expectedMethod string, body *string) {
func (f FakeHandler) ValidateRequest(t TestInterface, expectedPath, expectedMethod string, body *string) {
if f.RequestReceived.URL.Path != expectedPath {
t.Errorf("Unexpected request path: %s", f.RequestReceived.URL.Path)
}