renamed http_mock
This commit is contained in:
parent
61e3d7605b
commit
36275689b0
|
@ -15,7 +15,7 @@ type MockResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type MockServerProcedure struct {
|
type MockServerProcedure struct {
|
||||||
URL string
|
URI string
|
||||||
HTTPMethod string
|
HTTPMethod string
|
||||||
Response MockResponse
|
Response MockResponse
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ func NewMockServer(rec MockRecorder, procedures ...MockServerProcedure) *httptes
|
||||||
|
|
||||||
for _, proc := range procedures {
|
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()
|
headers := w.Header()
|
||||||
for hkey, hvalue := range proc.Response.Headers {
|
for hkey, hvalue := range proc.Response.Headers {
|
|
@ -17,21 +17,21 @@ func TestHTTPMock(t *testing.T) {
|
||||||
|
|
||||||
procs := []test.MockServerProcedure{
|
procs := []test.MockServerProcedure{
|
||||||
test.MockServerProcedure{
|
test.MockServerProcedure{
|
||||||
URL: "/",
|
URI: "/",
|
||||||
HTTPMethod: "GET",
|
HTTPMethod: "GET",
|
||||||
Response: test.MockResponse{
|
Response: test.MockResponse{
|
||||||
Body: []byte("getRoot"),
|
Body: []byte("getRoot"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
test.MockServerProcedure{
|
test.MockServerProcedure{
|
||||||
URL: "/",
|
URI: "/",
|
||||||
HTTPMethod: "POST",
|
HTTPMethod: "POST",
|
||||||
Response: test.MockResponse{
|
Response: test.MockResponse{
|
||||||
Body: []byte("postRoot"),
|
Body: []byte("postRoot"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
test.MockServerProcedure{
|
test.MockServerProcedure{
|
||||||
URL: "/get/header",
|
URI: "/get/header",
|
||||||
HTTPMethod: "GET",
|
HTTPMethod: "GET",
|
||||||
Response: test.MockResponse{
|
Response: test.MockResponse{
|
||||||
StatusCode: http.StatusAccepted,
|
StatusCode: http.StatusAccepted,
|
||||||
|
@ -42,21 +42,21 @@ func TestHTTPMock(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
test.MockServerProcedure{
|
test.MockServerProcedure{
|
||||||
URL: "/get/auth",
|
URI: "/get/auth",
|
||||||
HTTPMethod: "GET",
|
HTTPMethod: "GET",
|
||||||
Response: test.MockResponse{
|
Response: test.MockResponse{
|
||||||
Body: []byte("getRootAuth"),
|
Body: []byte("getRootAuth"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
test.MockServerProcedure{
|
test.MockServerProcedure{
|
||||||
URL: "/my_account",
|
URI: "/my_account",
|
||||||
HTTPMethod: "GET",
|
HTTPMethod: "GET",
|
||||||
Response: test.MockResponse{
|
Response: test.MockResponse{
|
||||||
Body: []byte("getAccount"),
|
Body: []byte("getAccount"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
test.MockServerProcedure{
|
test.MockServerProcedure{
|
||||||
URL: "/my_account.json",
|
URI: "/my_account.json",
|
||||||
HTTPMethod: "GET",
|
HTTPMethod: "GET",
|
||||||
Response: test.MockResponse{
|
Response: test.MockResponse{
|
||||||
Body: []byte("getAccountJSON"),
|
Body: []byte("getAccountJSON"),
|
||||||
|
@ -240,7 +240,7 @@ func ExampleMockAssertion_Hits() {
|
||||||
uri := "/"
|
uri := "/"
|
||||||
|
|
||||||
server := test.NewMockServer(&record, test.MockServerProcedure{
|
server := test.NewMockServer(&record, test.MockServerProcedure{
|
||||||
URL: uri,
|
URI: uri,
|
||||||
HTTPMethod: http.MethodGet,
|
HTTPMethod: http.MethodGet,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ func ExampleMockAssertion_Headers() {
|
||||||
uri := "/"
|
uri := "/"
|
||||||
|
|
||||||
server := test.NewMockServer(&record, test.MockServerProcedure{
|
server := test.NewMockServer(&record, test.MockServerProcedure{
|
||||||
URL: uri,
|
URI: uri,
|
||||||
HTTPMethod: http.MethodPost,
|
HTTPMethod: http.MethodPost,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ func ExampleMockAssertion_Body() {
|
||||||
uri := "/"
|
uri := "/"
|
||||||
|
|
||||||
server := test.NewMockServer(&record, test.MockServerProcedure{
|
server := test.NewMockServer(&record, test.MockServerProcedure{
|
||||||
URL: uri,
|
URI: uri,
|
||||||
HTTPMethod: http.MethodPost,
|
HTTPMethod: http.MethodPost,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue