mtcs-garage/tests/test_cli.rs
2024-08-13 15:29:57 +02:00

35 lines
815 B
Rust

use assert_cmd::prelude::*;
use predicates::prelude::*;
use rand;
use std::process::Command;
use rstest::*;
use mtcs_garage::*;
use hex;
#[fixture]
fn cmd() -> Command {
Command::cargo_bin("credit5000").unwrap()
}
#[rstest]
fn cli_showes_help(mut cmd: Command) -> Result<(), Box<dyn std::error::Error>> {
cmd.arg("--help");
cmd.assert().stdout(predicate::str::contains("Usage: credit5000"));
Ok(())
}
#[rstest]
fn cli_stuff(mut cmd: Command) -> Result<(), Box<dyn std::error::Error>> {
let o = cmd.args([
"--secret", &hex::encode(rand::random::<Secret>()),
"--from", &hex::encode(rand::random::<Address>()),
"--to", &hex::encode(rand::random::<Address>()),
"--value", "1000",
]);
cmd.assert().stdout(predicate::str::contains("coool"));
Ok(())
}