Co-authored-by: tahahawa <tahahawa@gmail.com> Reviewed-on: #9 Reviewed-by: johnride <jg@nationtech.io> Co-authored-by: Taha Hawa <taha@taha.dev> Co-committed-by: Taha Hawa <taha@taha.dev>
This commit is contained in:
38
examples/cli/src/main.rs
Normal file
38
examples/cli/src/main.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use harmony::{
|
||||
inventory::Inventory,
|
||||
maestro::Maestro,
|
||||
modules::dummy::{ErrorScore, PanicScore, SuccessScore},
|
||||
topology::HAClusterTopology,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let inventory = Inventory::autoload();
|
||||
let topology = HAClusterTopology::autoload();
|
||||
let mut maestro = Maestro::new(inventory, topology);
|
||||
|
||||
maestro.register_all(vec![
|
||||
Box::new(SuccessScore {}),
|
||||
Box::new(ErrorScore {}),
|
||||
Box::new(PanicScore {}),
|
||||
]);
|
||||
harmony_cli::init(maestro, None).await.unwrap();
|
||||
}
|
||||
|
||||
use assert_cmd::Command;
|
||||
|
||||
#[test]
|
||||
fn test_example_success() {
|
||||
let mut cmd = Command::cargo_bin("example-cli").unwrap();
|
||||
let assert = cmd.args(&["--yes", "--filter", "SuccessScore"]).assert();
|
||||
|
||||
assert.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_example_fail() {
|
||||
let mut cmd_fail = Command::cargo_bin("example-cli").unwrap();
|
||||
let assert_fail = cmd_fail.args(&["--yes", "--filter", "ErrorScore"]).assert();
|
||||
|
||||
assert_fail.failure();
|
||||
}
|
||||
Reference in New Issue
Block a user