summaryrefslogtreecommitdiffstats
path: root/utils/testutils
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2018-09-26 12:42:51 -0400
committerGitHub <noreply@github.com>2018-09-26 12:42:51 -0400
commit4e59a27293394b6d5529efd13ad711daebbc0eb3 (patch)
tree51094fc76cfc6295d136e4ebbefbc3cac19c650a /utils/testutils
parent15d64fb201848002a25facc3bbffc9535a704df6 (diff)
downloadchat-4e59a27293394b6d5529efd13ad711daebbc0eb3.tar.gz
chat-4e59a27293394b6d5529efd13ad711daebbc0eb3.tar.bz2
chat-4e59a27293394b6d5529efd13ad711daebbc0eb3.zip
Move HTTPService and ConfigService into services package (#9422)
* Move HTTPService and ConfigService into utils package * Re-add StaticConfigService * Move config and http services into their own packages
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) {
+
+}