From 5e1e3e1ec1b9e8b4fe8687d16dc05d1ab75926a3 Mon Sep 17 00:00:00 2001 From: Bret Harrison Date: Tue, 6 Mar 2018 14:07:35 -0500 Subject: [PATCH] FAB-8678 NodeSDK - packager missing logger The base class of the chaincode packagers is missing the logger definition. Fix that and add a test case to verify. Change-Id: Ib77714ee7c7cb7d6d68a9157d5e545b4c3439d53 Signed-off-by: Bret Harrison --- fabric-client/lib/packager/BasePackager.js | 9 +++++++-- test/unit/packager.js | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/fabric-client/lib/packager/BasePackager.js b/fabric-client/lib/packager/BasePackager.js index abbd91c34a..c2380ce99f 100644 --- a/fabric-client/lib/packager/BasePackager.js +++ b/fabric-client/lib/packager/BasePackager.js @@ -19,6 +19,9 @@ var klaw = require('klaw'); var tar = require('tar-stream'); var path = require('path'); var zlib = require('zlib'); +const utils = require('../utils.js'); + +let logger = utils.getLogger('packager/BasePackager.js'); var BasePackager = class { @@ -69,6 +72,7 @@ var BasePackager = class { */ findMetadataDescriptors (filePath) { return new Promise((resolve, reject) => { + logger.debug('findMetadataDescriptors : start'); var descriptors = []; klaw(filePath).on('data', (entry) => { if (entry.stats.isFile() && this.isMetadata(entry.path)) { @@ -77,11 +81,12 @@ var BasePackager = class { name: path.join('META-INF', path.relative(filePath, entry.path).split('\\').join('/')), // for windows style paths fqp: entry.path }; + logger.debug(' findMetadataDescriptors :: %j', desc); descriptors.push(desc); } }) .on('error', (error, item) => { - logger.error(`error while packaging ${item.path}`); + logger.error('error while packaging item %j :: %s', item, error); reject(error); }) .on('end', () => { @@ -190,4 +195,4 @@ var BasePackager = class { }; -module.exports = BasePackager; \ No newline at end of file +module.exports = BasePackager; diff --git a/test/unit/packager.js b/test/unit/packager.js index 796c3bccbd..13295852cd 100644 --- a/test/unit/packager.js +++ b/test/unit/packager.js @@ -58,6 +58,13 @@ test('\n\n** BasePackager tests **\n\n', function(t) { t.comment(err.stack ? err.stack : err); }); + golang.findMetadataDescriptors('/somepath') + .then((descriptors) => { + t.fail('Should have thrown an exception'); + }).catch((err) => { + t.pass('Golang.findMetadataDescriptors() pass with expected error'); + t.comment(err.stack ? err.stack : err); + }); t.end(); });