Skip to content

Commit

Permalink
FAB-8678 NodeSDK - packager missing logger
Browse files Browse the repository at this point in the history
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 <beharrison@nc.rr.com>
  • Loading branch information
harrisob committed Mar 6, 2018
1 parent 210dc90 commit 5e1e3e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fabric-client/lib/packager/BasePackager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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)) {
Expand All @@ -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', () => {
Expand Down Expand Up @@ -190,4 +195,4 @@ var BasePackager = class {

};

module.exports = BasePackager;
module.exports = BasePackager;
7 changes: 7 additions & 0 deletions test/unit/packager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down

0 comments on commit 5e1e3e1

Please sign in to comment.