~ewintr/go-kit

36275689b0ea717ba5621135ff998d3561cd47a3 — Erik Winter 2 months ago 61e3d76 master
renamed http_mock
2 files changed, 11 insertions(+), 11 deletions(-)

R test/{http_mock.go => httpmock.go}
R test/{http_mock_test.go => httpmock_test.go}
R test/http_mock.go => test/httpmock.go +2 -2
@@ 15,7 15,7 @@ type MockResponse struct {
}

type MockServerProcedure struct {
	URL        string
	URI        string
	HTTPMethod string
	Response   MockResponse
}


@@ 157,7 157,7 @@ func NewMockServer(rec MockRecorder, procedures ...MockServerProcedure) *httptes

			for _, proc := range procedures {

				if proc.URL == r.URL.RequestURI() && proc.HTTPMethod == r.Method {
				if proc.URI == r.URL.RequestURI() && proc.HTTPMethod == r.Method {

					headers := w.Header()
					for hkey, hvalue := range proc.Response.Headers {

R test/http_mock_test.go => test/httpmock_test.go +9 -9
@@ 17,21 17,21 @@ func TestHTTPMock(t *testing.T) {

	procs := []test.MockServerProcedure{
		test.MockServerProcedure{
			URL:        "/",
			URI:        "/",
			HTTPMethod: "GET",
			Response: test.MockResponse{
				Body: []byte("getRoot"),
			},
		},
		test.MockServerProcedure{
			URL:        "/",
			URI:        "/",
			HTTPMethod: "POST",
			Response: test.MockResponse{
				Body: []byte("postRoot"),
			},
		},
		test.MockServerProcedure{
			URL:        "/get/header",
			URI:        "/get/header",
			HTTPMethod: "GET",
			Response: test.MockResponse{
				StatusCode: http.StatusAccepted,


@@ 42,21 42,21 @@ func TestHTTPMock(t *testing.T) {
			},
		},
		test.MockServerProcedure{
			URL:        "/get/auth",
			URI:        "/get/auth",
			HTTPMethod: "GET",
			Response: test.MockResponse{
				Body: []byte("getRootAuth"),
			},
		},
		test.MockServerProcedure{
			URL:        "/my_account",
			URI:        "/my_account",
			HTTPMethod: "GET",
			Response: test.MockResponse{
				Body: []byte("getAccount"),
			},
		},
		test.MockServerProcedure{
			URL:        "/my_account.json",
			URI:        "/my_account.json",
			HTTPMethod: "GET",
			Response: test.MockResponse{
				Body: []byte("getAccountJSON"),


@@ 240,7 240,7 @@ func ExampleMockAssertion_Hits() {
	uri := "/"

	server := test.NewMockServer(&record, test.MockServerProcedure{
		URL:        uri,
		URI:        uri,
		HTTPMethod: http.MethodGet,
	})



@@ 255,7 255,7 @@ func ExampleMockAssertion_Headers() {
	uri := "/"

	server := test.NewMockServer(&record, test.MockServerProcedure{
		URL:        uri,
		URI:        uri,
		HTTPMethod: http.MethodPost,
	})



@@ 270,7 270,7 @@ func ExampleMockAssertion_Body() {
	uri := "/"

	server := test.NewMockServer(&record, test.MockServerProcedure{
		URL:        uri,
		URI:        uri,
		HTTPMethod: http.MethodPost,
	})