From 4e59a27293394b6d5529efd13ad711daebbc0eb3 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Wed, 26 Sep 2018 12:42:51 -0400 Subject: 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 --- app/apptestlib.go | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'app/apptestlib.go') diff --git a/app/apptestlib.go b/app/apptestlib.go index c0d2cfaa2..dcc1fa941 100644 --- a/app/apptestlib.go +++ b/app/apptestlib.go @@ -7,7 +7,6 @@ import ( "io" "io/ioutil" "net/http" - "net/http/httptest" "os" "path/filepath" "time" @@ -21,6 +20,7 @@ import ( "github.com/mattermost/mattermost-server/store/sqlstore" "github.com/mattermost/mattermost-server/store/storetest" "github.com/mattermost/mattermost-server/utils" + "github.com/mattermost/mattermost-server/utils/testutils" ) type TestHelper struct { @@ -36,7 +36,7 @@ type TestHelper struct { tempConfigPath string tempWorkspace string - MockedHTTPService *MockedHTTPService + MockedHTTPService *testutils.MockedHTTPService } type persistentTestStore struct { @@ -168,7 +168,7 @@ func (me *TestHelper) InitSystemAdmin() *TestHelper { } func (me *TestHelper) MockHTTPService(handler http.Handler) *TestHelper { - me.MockedHTTPService = MakeMockedHTTPService(handler) + me.MockedHTTPService = testutils.MakeMockedHTTPService(handler) me.App.HTTPService = me.MockedHTTPService return me @@ -514,22 +514,3 @@ func (me *FakeClusterInterface) sendClearRoleCacheMessage() { Event: model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_ROLES, }) } - -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() -} -- cgit v1.2.3-1-g7c22