Skip to content

Commit

Permalink
[FAB-6612] Handle Windows tempdir in node-sdk test
Browse files Browse the repository at this point in the history
This CR escapes the filepath used for the debug logger on
Windows so that HFC_LOGGING contains properly formatted JSON
and can be parsed successfully.

Before:
$ gulp test-headless
...
[17:15:43] Starting 'test-headless'...
[17:15:43] Starting 'test-headless'...
warn: Failed to parse environment variable "HFC_LOGGING". Returned
 a winston logger with default configurations. Error:
SyntaxError: Unexpected token U in JSON at position 13
    at Object.parse (native)
...

$ ll ~/AppData/Local/Temp/hfc/test-log/debug.log
-rwx------+ 1 lehors None 0 Oct 13 17:15 /home/lehors/AppData/Local
/Temp/hfc/test-log/debug.log

After:
$ gulp test-headless
...
[17:17:34] Starting 'test-headless'...

TAP version 13

*** BlockDecoder test for readwrite sets
ok 1 Successfully build a results proto with read and write sets
...

$ ll ~/AppData/Local/Temp/hfc/test-log/debug.log
-rw-r--r-- 1 lehors 197121 462970 Oct 13 17:18 /c/Users/lehors/AppD
ata/Local/Temp/hfc/test-log/debug.log

This CR also fixes a typo in the fabric-ca-client tests.

Change-Id: Ia767aa135eb8803608de0322d7e4675326026b08
Signed-off-by: Arnaud J Le Hors <[email protected]>
  • Loading branch information
lehors committed Oct 13, 2017
1 parent fafeb2a commit 95599c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 7 additions & 1 deletion build/tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ var testConstants = require('../../test/unit/constants.js');

// by default for running the tests print debug to a file
var debugPath = path.join(testConstants.tempdir, 'test-log/debug.log');
process.env.HFC_LOGGING = util.format('{"debug":"%s"}', debugPath);
process.env.HFC_LOGGING = util.format('{"debug":"%s"}', escapeWindowsPath(debugPath));

function escapeWindowsPath(p) {
if (path.sep == "/") return p
return p.replace(/\\/g, "\\\\")
}

console.log('\n####################################################');
console.log(util.format('# debug log: %s', debugPath));
console.log('####################################################\n');
Expand Down
12 changes: 6 additions & 6 deletions test/unit/fabric-ca-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ test('FabricCAServices: Test newCryptoKeyStore() function', function(t) {
}
t.end();
});
// Test optional consturctor
test('FabricCAServices: Test optional consturctor', function(t) {
// Test optional constructor
test('FabricCAServices: Test optional constructor', function(t) {
let opts = {
url : 'http://localhost:7054'
}
Expand All @@ -280,7 +280,7 @@ test('FabricCAServices: Test optional consturctor', function(t) {
let service = new FabricCAServices(opts);
},
null,
'FabricCAServices consturctor with object and just url'
'FabricCAServices constructor with object and just url'
);

opts.caName = 'someca';
Expand All @@ -290,7 +290,7 @@ test('FabricCAServices: Test optional consturctor', function(t) {
t.equals(service._fabricCAClient._caName,'someca','Caname should have been passed correctly');
},
null,
'FabricCAServices consturctor with object and just url'
'FabricCAServices constructor with object and just url'
);

opts.cryptoSuite = 'somesuite';
Expand All @@ -300,7 +300,7 @@ test('FabricCAServices: Test optional consturctor', function(t) {
t.equals(service._fabricCAClient._cryptoPrimitives,'somesuite','CryptoSuite should have been passed correctly');
},
null,
'FabricCAServices consturctor with object and just url'
'FabricCAServices constructor with object and just url'
);

opts.tlsOptions = {verify : 'someverify'};
Expand All @@ -310,7 +310,7 @@ test('FabricCAServices: Test optional consturctor', function(t) {
t.equals(service._fabricCAClient._tlsOptions.verify,'someverify','tlsOptions should have been passed correctly');
},
null,
'FabricCAServices consturctor with object and just url'
'FabricCAServices constructor with object and just url'
);

t.end();
Expand Down

0 comments on commit 95599c0

Please sign in to comment.