Skip to content

Commit 15b13d2

Browse files
committed
fix: tests
1 parent 4e6dda5 commit 15b13d2

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

test/addNewMask.unit.spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ describe('addNewMask', () => {
5757
stubGot.post.resolves({ statusCode: 201 });
5858

5959
const { updateMasks, exitHandler } = proxyquire('../lib/addNewMask', {
60+
'@codefresh-io/cf-telemetry/init': {
61+
terminate: () => ({
62+
finally: callback => callback(),
63+
})
64+
},
6065
'./helpers': { getServerAddress: stubGetServerAddress },
6166
});
6267
process.listeners('exit').forEach((listener) => {
@@ -77,6 +82,11 @@ describe('addNewMask', () => {
7782
it('should fail if the server address is not available', async () => {
7883
stubGetServerAddress.rejects('could not get server address');
7984
const { updateMasks, exitHandler } = proxyquire('../lib/addNewMask', {
85+
'@codefresh-io/cf-telemetry/init': {
86+
terminate: () => ({
87+
finally: callback => callback(),
88+
})
89+
},
8090
'@codefresh-io/cf-telemetry/logs': {
8191
Logger: function() { return stubLogger },
8292
},
@@ -97,6 +107,11 @@ describe('addNewMask', () => {
97107
it('should fail if the server address is not valid URL', async () => {
98108
stubGetServerAddress.resolves('foo');
99109
const { updateMasks, exitHandler } = proxyquire('../lib/addNewMask', {
110+
'@codefresh-io/cf-telemetry/init': {
111+
terminate: () => ({
112+
finally: callback => callback(),
113+
})
114+
},
100115
'@codefresh-io/cf-telemetry/logs': {
101116
Logger: function() { return stubLogger },
102117
},
@@ -122,6 +137,11 @@ describe('addNewMask', () => {
122137
body: 'Internal Server Error',
123138
});
124139
const { updateMasks, exitHandler } = proxyquire('../lib/addNewMask', {
140+
'@codefresh-io/cf-telemetry/init': {
141+
terminate: () => ({
142+
finally: callback => callback(),
143+
})
144+
},
125145
'@codefresh-io/cf-telemetry/logs': {
126146
Logger: function() { return stubLogger },
127147
},

test/isReady.unit.spec.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ describe('isReady script', () => {
2222
const state = JSON.stringify({ status: 'ready', containers: {} })
2323
process.argv = [];
2424
proxyquire('../lib/isReady.js', {
25+
'@codefresh-io/cf-telemetry/init': {
26+
terminate: () => ({
27+
finally: callback => callback(),
28+
})
29+
},
2530
'fs': {
2631
readFileSync: () => Buffer.from(state),
2732
},
@@ -32,6 +37,11 @@ describe('isReady script', () => {
3237
const state = JSON.stringify({ status: 'notReady', containers: {} })
3338
process.argv = [];
3439
proxyquire('../lib/isReady.js', {
40+
'@codefresh-io/cf-telemetry/init': {
41+
terminate: () => ({
42+
finally: callback => callback(),
43+
})
44+
},
3545
'fs': {
3646
readFileSync: () => Buffer.from(state),
3747
},
@@ -44,6 +54,11 @@ describe('isReady script', () => {
4454
const state = JSON.stringify({ status: 'ready', containers: { 'container-id': { status: ContainerHandlingStatus.LISTENING } } })
4555
process.argv = ['foo', 'bar', 'container-id'];
4656
proxyquire('../lib/isReady.js', {
57+
'@codefresh-io/cf-telemetry/init': {
58+
terminate: () => ({
59+
finally: callback => callback(),
60+
})
61+
},
4762
'fs': {
4863
readFileSync: () => Buffer.from(state),
4964
},
@@ -54,6 +69,11 @@ describe('isReady script', () => {
5469
const state = JSON.stringify({ status: 'ready', containers: { 'container-id': { status: ContainerHandlingStatus.WAITING_FOR_START } } })
5570
process.argv = ['foo', 'bar', 'container-id'];
5671
proxyquire('../lib/isReady.js', {
72+
'@codefresh-io/cf-telemetry/init': {
73+
terminate: () => ({
74+
finally: callback => callback(),
75+
})
76+
},
5777
'fs': {
5878
readFileSync: () => Buffer.from(state),
5979
},
@@ -64,6 +84,11 @@ describe('isReady script', () => {
6484
const state = JSON.stringify({ status: 'ready', containers: { 'container-id': { status: ContainerHandlingStatus.FINISHED } } })
6585
process.argv = ['foo', 'bar', 'container-id'];
6686
proxyquire('../lib/isReady.js', {
87+
'@codefresh-io/cf-telemetry/init': {
88+
terminate: () => ({
89+
finally: callback => callback(),
90+
})
91+
},
6792
'fs': {
6893
readFileSync: () => Buffer.from(state),
6994
},
@@ -74,11 +99,16 @@ describe('isReady script', () => {
7499
const state = JSON.stringify({ status: 'ready', containers: { 'container-id': { status: ContainerHandlingStatus.INITIALIZING } } })
75100
process.argv = ['foo', 'bar', 'container-id'];
76101
proxyquire('../lib/isReady.js', {
102+
'@codefresh-io/cf-telemetry/init': {
103+
terminate: () => ({
104+
finally: callback => callback(),
105+
})
106+
},
77107
'fs': {
78108
readFileSync: () => Buffer.from(state),
79109
},
80110
});
81111
expect(process.exit).to.have.been.calledOnceWith(1);
82112
});
83113
});
84-
});
114+
});

0 commit comments

Comments
 (0)