Skip to content

Commit 883ba54

Browse files
committed
Fix memory limit tests for node 12
1 parent 0914a38 commit 883ba54

File tree

3 files changed

+37
-20
lines changed

3 files changed

+37
-20
lines changed

Diff for: lib/lambda.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function forkLambda(base_dir, lambda_path_tpl, name, environment, timeout,
9292

9393
const inspect_lambda = process.env.STUDIO_LAMBDA_INSPECT === name;
9494
const execArgv = process.execArgv.slice();
95-
execArgv.push(`--max_old_space_size=${memoryLimitInMB}`);
95+
execArgv.push(`--max-old-space-size=${memoryLimitInMB}`);
9696
if (inspect_lambda) {
9797
execArgv.push('--inspect');
9898
}

Diff for: test/fixture/functions/memory/function.local.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"memory": 16
2+
"memory": 8
33
}

Diff for: test/lambda-test.js

+35-18
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
process.env.AWS_PROFILE = 'studio-lambda-test';
55

6+
const fs = require('fs');
67
const path = require('path');
78
const { assert, sinon } = require('@sinonjs/referee-sinon');
89
const logger = require('@studio/log');
@@ -527,32 +528,48 @@ describe('lambda', () => {
527528
});
528529
});
529530

530-
it('runs node process with memory from config file', (done) => {
531-
sinon.stub(process.stderr, 'write');
531+
context('with memory limit', () => {
532532

533-
lambda = Lambda.create({
534-
env: {
535-
AWS_PROFILE: 'local'
536-
}
533+
after(() => {
534+
// Remove the node memory report.
535+
const dir = `${__dirname}/fixture/functions/memory`;
536+
// eslint-disable-next-line no-sync
537+
fs.readdirSync(dir)
538+
.filter((file) => file.startsWith('report.'))
539+
.forEach((file) => {
540+
// eslint-disable-next-line no-sync
541+
fs.unlinkSync(`${dir}/${file}`);
542+
});
537543
});
538544

539-
lambda.invoke('memory', {}, (err) => {
540-
assert.json(err, { code: 'ERR_FAILED' });
541-
done();
542-
});
543-
});
545+
it('runs node process with memory from config file', (done) => {
546+
sinon.stub(process.stderr, 'write');
544547

545-
it('runs node process with memory from property', (done) => {
546-
sinon.stub(process.stderr, 'write');
548+
lambda = Lambda.create({
549+
env: {
550+
AWS_PROFILE: 'local'
551+
}
552+
});
547553

548-
lambda = Lambda.create({
549-
memory: 16
554+
lambda.invoke('memory', {}, (err) => {
555+
assert.json(err, { code: 'ERR_FAILED' });
556+
done();
557+
});
550558
});
551559

552-
lambda.invoke('memory', {}, (err) => {
553-
assert.json(err, { code: 'ERR_FAILED' });
554-
done();
560+
it('runs node process with memory from property', (done) => {
561+
sinon.stub(process.stderr, 'write');
562+
563+
lambda = Lambda.create({
564+
memory: 8
565+
});
566+
567+
lambda.invoke('memory', {}, (err) => {
568+
assert.json(err, { code: 'ERR_FAILED' });
569+
done();
570+
});
555571
});
572+
556573
});
557574

558575
});

0 commit comments

Comments
 (0)