Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix to extend test timeout time in Windows
  • Loading branch information
abetomo committed May 2, 2017
commit b1630d054326ef7ad53589ffa614fb07ad36bfe5
29 changes: 22 additions & 7 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,28 @@ var originalProgram = {

var codeDirectory = lambda._codeDirectory(Hoek.clone(originalProgram));

function _timeout(params) {
// Even if timeout is set for the whole test for Windows,
// if it is set in local it will be valid.
// For Windows, do not set it with local.
if (process.platform != 'win32') {
params.this.timeout(params.sec * 1000);
}
}

describe('node-lambda', function () {
if (process.platform == 'win32') {
// It seems that it takes time for file operation in Windows.
// So set `timeout(60000)` for the whole test.
this.timeout(60000);
}

beforeEach(function () {
program = Hoek.clone(originalProgram);
});

after(function () {
this.timeout(30000); // give it time to remove
_timeout({ this: this, sec: 30 }); // give it time to remove
fs.removeSync(path.join(os.tmpDir(), `${program.functionName}-[0-9]*`));
});

Expand Down Expand Up @@ -305,7 +320,7 @@ describe('node-lambda', function () {
});

it('_npm adds node_modules', function (done) {
this.timeout(60000); // give it time to build the node modules
_timeout({ this: this, sec: 30 }); // give it time to build the node modules

lambda._npmInstall(program, codeDirectory, function (err, result) {
var contents = fs.readdirSync(codeDirectory);
Expand Down Expand Up @@ -375,7 +390,7 @@ describe('node-lambda', function () {

describe('_zip', function () {
beforeEach(function (done) {
this.timeout(30000); // give it time to build the node modules
_timeout({ this: this, sec: 30 }); // give it time to build the node modules
lambda._cleanDirectory(codeDirectory, function (err) {
if (err) {
return done(err);
Expand All @@ -396,7 +411,7 @@ describe('node-lambda', function () {
});

it('zips the file and has an index.js file', function (done) {
this.timeout(30000); // give it time to zip
_timeout({ this: this, sec: 30 }); // give it time to zip

lambda._zip(program, codeDirectory, function (err, data) {
var archive = new zip(data);
Expand All @@ -411,7 +426,7 @@ describe('node-lambda', function () {

describe('_archive', function () {
it('installs and zips with an index.js file and node_modules/async', function (done) {
this.timeout(30000); // give it time to zip
_timeout({ this: this, sec: 30 }); // give it time to zip

lambda._archive(program, function (err, data) {
var archive = new zip(data);
Expand Down Expand Up @@ -459,7 +474,7 @@ describe('node-lambda', function () {
const testZipFile = path.join(os.tmpDir(), 'node-lambda-test.zip');
var bufferExpected = null;
before(function(done) {
this.timeout(30000); // give it time to zip
_timeout({ this: this, sec: 30 }); // give it time to zip

lambda._zip(program, codeDirectory, function (err, data) {
bufferExpected = data;
Expand Down Expand Up @@ -505,7 +520,7 @@ describe('node-lambda', function () {
it('`deployZipfile` is a invalid value. Process from creation of zip file', function (done) {
const filePath = path.join(path.resolve('/aaaa'), 'bbbb');
const _program = Object.assign({ deployZipfile: filePath }, program);
this.timeout(30000); // give it time to zip
_timeout({ this: this, sec: 30 }); // give it time to zip
lambda._archive(_program, function (err, data) {
// same test as "installs and zips with an index.js file and node_modules/async"
var archive = new zip(data);
Expand Down