renamed http_mock

This commit is contained in:
Erik Winter 2020-07-04 13:20:30 +02:00
parent 61e3d7605b
commit 36275689b0
2 changed files with 11 additions and 11 deletions

View File

@ -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 {

View File

@ -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,
})