Skip to content

Commit

Permalink
CLI integration test for failing transaction (hyperledger-archives#4084)
Browse files Browse the repository at this point in the history
Signed-off-by: Mark S. Lewis <[email protected]>
  • Loading branch information
bestbeforetoday authored and nklincoln committed Jun 1, 2018
1 parent d7d685a commit fd0cead
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
26 changes: 23 additions & 3 deletions packages/composer-tests-integration/features/cli-network.feature
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ Feature: Cli network steps
Then The stdout information should include text matching /org.hyperledger_composer.marbles.NewMarble/
And The stdout information should include text matching /Command succeeded/

Scenario: Using the CLI, errors creating new assets are displayed to the user
When I run the following expected fail CLI command
"""
composer transaction submit
--card admin@marbles-network
-d '{
"$class": "org.hyperledger.composer.system.AddAsset",
"targetRegistry": "resource:org.hyperledger.composer.system.AssetRegistry#org.hyperledger_composer.marbles.NewMarble",
"resources": [{
"$class": "org.hyperledger_composer.marbles.NewMarble",
"marbleId": "101",
"size": "SMALL",
"color": "RED",
"owner": "resource:org.hyperledger_composer.marbles.Player#bob",
"ALL_YOUR_BASE_ARE_BELONG_TO_US": "A value"
}]
}'
"""
Then The stdout information should include text matching /ALL_YOUR_BASE_ARE_BELONG_TO_US/

Scenario: Using the CLI, I can create new Assets by submitting transactions
When I run the following expected pass CLI command
"""
Expand Down Expand Up @@ -161,7 +181,7 @@ Feature: Cli network steps
"""
composer network list --card admin@marbles-network
"""
Then I stop watching the chain code logs
Then I stop watching the chain code logs
And Then the maximum log level should be debug
And The stdout information should include text matching /Command succeeded/

Expand All @@ -185,6 +205,6 @@ Feature: Cli network steps
"""
composer network loglevel --card admin@marbles-network --newlevel 'composer[warn]:*'
"""
Then I stop watching the chain code logs
Then I stop watching the chain code logs
And Then the maximum log level should be info
And The stdout information should include text matching /Command succeeded/
And The stdout information should include text matching /Command succeeded/
2 changes: 1 addition & 1 deletion packages/composer-tests-integration/lib/clisteps.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = function () {
});

this.When(/^I run the following expected (.*?) CLI command/, {timeout: 240 * 1000}, function (condition, table) {
let pass = condition === 'pass' ? true : false;
const pass = (condition === 'pass');
return this.composer.runCLI(pass, table);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/composer-tests-integration/lib/composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ class Composer {
if (typeof cmd !== 'string') {
return Promise.reject('Command passed to function was not a string');
} else {
let command = cmd;
const command = cmd.replace(/\s*[\n\r]+\s*/g, ' ');
let stdout = '';
let stderr = '';
let env = Object.create( process.env );
Expand Down

0 comments on commit fd0cead

Please sign in to comment.