From a62ed69702ca8ff7b7460b9b330864403911b1e4 Mon Sep 17 00:00:00 2001 From: restrry Date: Wed, 19 Jun 2019 06:01:12 +0200 Subject: [PATCH] address @eli comments --- src/core/server/http/http_server.ts | 2 +- src/core/server/http/http_service.test.ts | 24 +++++++++++++++++++++++ src/core/server/http/http_service.ts | 6 ++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/core/server/http/http_server.ts b/src/core/server/http/http_server.ts index 39f517653bb79fa..eb571bdb47ddd1d 100644 --- a/src/core/server/http/http_server.ts +++ b/src/core/server/http/http_server.ts @@ -155,7 +155,7 @@ export class HttpServer { await this.server.start(); const serverPath = this.config!.rewriteBasePath || this.config!.basePath || ''; this.log.info('http server running'); - this.log.debug(`http server listens at ${this.server.info.uri}${serverPath}`); + this.log.debug(`http server listening on ${this.server.info.uri}${serverPath}`); } public async stop() { diff --git a/src/core/server/http/http_service.test.ts b/src/core/server/http/http_service.test.ts index d0c30ec561c79f3..f003ba1314434d2 100644 --- a/src/core/server/http/http_service.test.ts +++ b/src/core/server/http/http_service.test.ts @@ -214,6 +214,30 @@ test('stops http server', async () => { expect(httpServer.stop).toHaveBeenCalledTimes(1); }); +test('stops not ready server if it is running', async () => { + const configService = createConfigService(); + const mockHapiServer = { + start: jest.fn(), + stop: jest.fn(), + route: jest.fn(), + }; + const httpServer = { + isListening: () => false, + setup: jest.fn().mockReturnValue({ server: mockHapiServer }), + start: noop, + stop: jest.fn(), + }; + mockHttpServer.mockImplementation(() => httpServer); + + const service = new HttpService({ configService, env, logger }); + + await service.setup(); + + await service.stop(); + + expect(mockHapiServer.stop).toHaveBeenCalledTimes(1); +}); + test('register route handler', async () => { const configService = createConfigService(); diff --git a/src/core/server/http/http_service.ts b/src/core/server/http/http_service.ts index 0ca3d9a58af005e..a056300f6ed7eeb 100644 --- a/src/core/server/http/http_service.ts +++ b/src/core/server/http/http_service.ts @@ -94,7 +94,9 @@ export class HttpService implements CoreService s.stop())); @@ -169,6 +174,7 @@ export class HttpService implements CoreService