Skip to content

Commit

Permalink
Merge pull request #69 from steinfletcher/add-head-mock-matching-method
Browse files Browse the repository at this point in the history
Add mock method that matches http HEAD
  • Loading branch information
steinfletcher authored Feb 18, 2020
2 parents 849b0f6 + 306d24e commit fee5589
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,13 @@ func (m *Mock) Get(u string) *MockRequest {
return m.request
}

// Head configures the mock to match http method HEAD
func (m *Mock) Head(u string) *MockRequest {
m.parseUrl(u)
m.request.method = http.MethodHead
return m.request
}

// Put configures the mock to match http method PUT
func (m *Mock) Put(u string) *MockRequest {
m.parseUrl(u)
Expand Down
1 change: 1 addition & 0 deletions mocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ func TestMocks_Request_SetsTheMethod(t *testing.T) {
{http.MethodPut, func(m *Mock) { m.Put("/") }},
{http.MethodDelete, func(m *Mock) { m.Delete("/") }},
{http.MethodPatch, func(m *Mock) { m.Patch("/") }},
{http.MethodHead, func(m *Mock) { m.Head("/") }},
}
for _, test := range tests {
t.Run(test.expectedMethod, func(t *testing.T) {
Expand Down

0 comments on commit fee5589

Please sign in to comment.