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
Этот коммит содержится в:
Harrison Healey
2018-09-26 12:42:51 -04:00
коммит произвёл GitHub
родитель 15d64fb201
Коммит 4e59a27293
11 изменённых файлов: 147 добавлений и 110 удалений

28
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()
}

24
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) {
}