From d0e6b3277a90f6d88dffad2a5137967521c5340b Mon Sep 17 00:00:00 2001 From: abetomo Date: Tue, 4 Apr 2017 17:11:29 +0900 Subject: [PATCH] Add _readArchive tests called in _archive --- test/main.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/main.js b/test/main.js index 3e9e25fc..df37d029 100644 --- a/test/main.js +++ b/test/main.js @@ -411,6 +411,34 @@ describe('node-lambda', function () { done(); }); }); + + describe('If value is set in `deployZipfile`, _readArchive is executed in _archive', function () { + it('`deployZipfile` is a invalid value. Process from creation of zip file', function (done) { + const _program = Object.assign({ deployZipfile: '/aaaa/bbbb' }, program); + this.timeout(30000); // 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); + var contents = _.map(archive.files, function (f) { + return f.name.toString(); + }); + var result = _.includes(contents, 'index.js'); + assert.equal(result, true); + result = _.includes(contents, 'node_modules/async/lib/async.js'); + assert.equal(result, true); + done(); + }); + }); + + it('`deployZipfile` is a valid value._archive reads the contents of the zipfile', function (done) { + const _program = Object.assign({ deployZipfile: testZipFile }, program); + lambda._archive(_program, function (err, data) { + assert.isNull(err); + assert.deepEqual(data, bufferExpected); + done(); + }); + }); + }); }); describe('environment variable injection at runtime', function () {