From 306d24e766acff3cb42d973794f73a3f1a1e5996 Mon Sep 17 00:00:00 2001 From: billbell73 Date: Tue, 18 Feb 2020 12:42:03 +0000 Subject: [PATCH] Add mock method that matches http HEAD --- mocks.go | 7 +++++++ mocks_test.go | 1 + 2 files changed, 8 insertions(+) diff --git a/mocks.go b/mocks.go index 63316c8..f24f8e4 100644 --- a/mocks.go +++ b/mocks.go @@ -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) diff --git a/mocks_test.go b/mocks_test.go index c7e8071..2828c84 100644 --- a/mocks_test.go +++ b/mocks_test.go @@ -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) {