Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI testing #4

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ serde_json = { version = "1.0", features = ["raw_value"] }

juan518munoz marked this conversation as resolved.
Show resolved Hide resolved
[dev-dependencies]
ctor = "0.2.5"
assert_cmd = "2.0.12"
predicates = "3.0.4"
escargot = "0.5.8"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed offline, if it's easy to work around, let's try to remove crates or try to make sure they are no_std compatible. If there is no good alternative, it's fine to add them for now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert_cmd doesn't support running with features, using escargot seems mandatory, nevertheless, it is no std compatible.

50 changes: 50 additions & 0 deletions tests/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use assert_cmd::prelude::*; // Add methods on commands
use escargot::CargoBuild;
use predicates::prelude::*; // Used for writing assertions

#[test]
fn test_cli_create_account_works() -> Result<(), Box<dyn std::error::Error>> {
let run = CargoBuild::new()
.bin(env!("CARGO_PKG_NAME"))
.release()
.features("testing")
.run()
.unwrap()
.command()
.args([
"account",
"new",
"fungible-faucet",
"-t",
"TEST",
"-d",
"10",
"-m",
"10000",
])
.unwrap();

run.assert().success().stdout(predicate::str::contains(
"Succesfully created and stored Account ID:",
));

Ok(())
}

#[test]
fn test_cli_list_accounts() -> Result<(), Box<dyn std::error::Error>> {
let run = CargoBuild::new()
.bin(env!("CARGO_PKG_NAME"))
.release()
.features("testing")
.run()
.unwrap()
.command()
.args(["account", "list"])
.unwrap();

run.assert()
.success()
.stdout(predicate::str::contains("| storage root"));
Ok(())
}