summaryrefslogtreecommitdiffstats
path: root/utils/testutils
diff options
context:
space:
mode:
Diffstat (limited to 'utils/testutils')
-rw-r--r--utils/testutils/mocked_http_service.go28
-rw-r--r--utils/testutils/static_config_service.go24
2 files changed, 52 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()
+}
diff --git a/utils/testutils/static_config_service.go b/utils/testutils/static_config_service.go
new file mode 100644
index 000000000..44705ff6e
--- /dev/null
+++ b/utils/testutils/static_config_service.go
@@ -0,0 +1,24 @@
+// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package testutils
+
+import (
+ "github.com/mattermost/mattermost-server/model"
+)
+
+type StaticConfigService struct {
+ Cfg *model.Config
+}
+
+func (s StaticConfigService) Config() *model.Config {
+ return s.Cfg
+}
+
+func (StaticConfigService) AddConfigListener(func(old, current *model.Config)) string {
+ return ""
+}
+
+func (StaticConfigService) RemoveConfigListener(string) {
+
+}