@@ -14,10 +14,12 @@ chai.use(sinonChai);
1414
1515const mockAddress = 'mockAddress' ;
1616const stubFastifyPost = sinon . stub ( ) ;
17+ const stubFastifyGet = sinon . stub ( ) ;
1718const stubFastifyListen = sinon . stub ( ) . resolves ( mockAddress ) ;
1819const stubFastify = sinon . stub ( ) . returns ( {
1920 listen : stubFastifyListen ,
2021 post : stubFastifyPost ,
22+ get : stubFastifyGet ,
2123} ) ;
2224const stubSaveServerAddress = sinon . stub ( ) . resolves ( ) ;
2325
@@ -1696,11 +1698,17 @@ describe('Logger tests', () => {
16961698 } ;
16971699 const TaskLoggerFactory = sinon . spy ( async ( ) => taskLogger ) ;
16981700
1701+ const HttpServer = proxyquire ( '../lib/http-server' , {
1702+ 'fastify' : stubFastify ,
1703+ '../helpers' : {
1704+ saveServerAddress : stubSaveServerAddress ,
1705+ }
1706+ } ) ;
1707+
16991708 const Logger = proxyquire ( '../lib/logger' , {
17001709 '@codefresh-io/task-logger' : { TaskLogger : TaskLoggerFactory } ,
1701- 'fastify ' : stubFastify ,
1710+ './http-server ' : HttpServer ,
17021711 './helpers' : {
1703- saveServerAddress : stubSaveServerAddress ,
17041712 getPromiseWithResolvers,
17051713 } ,
17061714 } ) ;
@@ -1709,6 +1717,8 @@ describe('Logger tests', () => {
17091717 const taskLoggerConfig = { task : { } , opts : { } } ;
17101718 const findExistingContainers = false ;
17111719
1720+ process . env . PORT = 1337 ;
1721+ process . env . HOST = '127.0.0.1' ;
17121722 const logger = new Logger ( {
17131723 loggerId,
17141724 taskLoggerConfig,
@@ -1717,8 +1727,6 @@ describe('Logger tests', () => {
17171727 logger . _listenForNewContainers = sinon . spy ( ) ;
17181728 logger . _writeNewState = sinon . spy ( ) ;
17191729 logger . _listenForExistingContainers = sinon . spy ( ) ;
1720- process . env . PORT = 1337 ;
1721- process . env . HOST = '127.0.0.1' ;
17221730 await logger . start ( ) ;
17231731
17241732 expect ( stubFastify ) . to . have . been . calledOnce ;
@@ -1739,9 +1747,13 @@ describe('Logger tests', () => {
17391747 } ;
17401748 const TaskLoggerFactory = sinon . spy ( async ( ) => taskLogger ) ;
17411749
1750+ const HttpServer = proxyquire ( '../lib/http-server' , {
1751+ 'fastify' : stubFastify ,
1752+ } ) ;
1753+
17421754 const Logger = proxyquire ( '../lib/logger' , {
17431755 '@codefresh-io/task-logger' : { TaskLogger : TaskLoggerFactory } ,
1744- 'fastify ' : stubFastify ,
1756+ './http-server ' : HttpServer ,
17451757 './helpers' : {
17461758 saveServerAddress : stubSaveServerAddress ,
17471759 getPromiseWithResolvers,
0 commit comments