summaryrefslogtreecommitdiffstats
path: root/utils/testutils/mocked_http_service.go
diff options
context:
space:
mode:
Diffstat (limited to 'utils/testutils/mocked_http_service.go')
-rw-r--r--utils/testutils/mocked_http_service.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/utils/testutils/mocked_http_service.go b/utils/testutils/mocked_http_service.go
new file mode 100644
index 000000000..b1e7f6963
--- /dev/null
+++ b/utils/testutils/mocked_http_service.go
@@ -0,0 +1,28 @@
+// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package testutils
+
+import (
+ "net/http"
+ "net/http/httptest"
+)
+
+type MockedHTTPService struct {
+ Server *httptest.Server
+}
+
+func MakeMockedHTTPService(handler http.Handler) *MockedHTTPService {
+ return &MockedHTTPService{
+ Server: httptest.NewServer(handler),
+ }
+}
+
+func (h *MockedHTTPService) MakeClient(trustURLs bool) *http.Client {
+ return h.Server.Client()
+}
+
+func (h *MockedHTTPService) Close() {
+ h.Server.CloseClientConnections()
+ h.Server.Close()
+}