Skip to content

Commit cfd18eb

Browse files
Wesseldrdanielbayerlein
authored andcommitted
FIX #27, pidusage.stat not a function (#28)
1 parent 1ddc160 commit cfd18eb

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

__tests__/helpers/gather-os-metrics.spec.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
const gatherOsMetrics = require('../../src/helpers/gather-os-metrics');
2+
3+
jest.mock('pidusage');
24
const pidusage = require('pidusage');
35

46
describe('helpers', () => {
57
describe('gather-os-metrics', () => {
68
describe('when invoked', () => {
7-
it('then pidusage.stat should be called', () => {
8-
const span = { os: [], responses: [] };
9-
pidusage.stat = jest.fn();
10-
11-
gatherOsMetrics({}, span);
12-
13-
expect(pidusage.stat).toHaveBeenCalled();
9+
it('then pidusage should be called', () => {
10+
gatherOsMetrics({}, { os: [], responses: [] });
11+
expect(pidusage).toHaveBeenCalled();
1412
});
1513
});
1614
});

src/helpers/gather-os-metrics.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = (io, span) => {
1313
timestamp: Date.now(),
1414
};
1515

16-
pidusage.stat(process.pid, (err, stat) => {
16+
pidusage(process.pid, (err, stat) => {
1717
if (err) {
1818
console.error(err); // eslint-disable-line no-console
1919
return;

0 commit comments

Comments
 (0)