extracted test function
This commit is contained in:
parent
2d97cac64b
commit
09e61eaabc
@ -148,9 +148,9 @@ mod test {
|
||||
modules::dummy::{ErrorScore, PanicScore, SuccessScore},
|
||||
topology::HAClusterTopology,
|
||||
};
|
||||
use harmony::{score::Score, topology::Topology};
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_init_success_score() {
|
||||
fn init_test_maestro() -> Maestro<HAClusterTopology> {
|
||||
let inventory = Inventory::autoload();
|
||||
let topology = HAClusterTopology::autoload();
|
||||
let mut maestro = Maestro::new(inventory, topology);
|
||||
@ -161,6 +161,12 @@ mod test {
|
||||
Box::new(PanicScore {}),
|
||||
]);
|
||||
|
||||
maestro
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_init_success_score() {
|
||||
let maestro = init_test_maestro();
|
||||
let res = crate::init(
|
||||
maestro,
|
||||
Some(crate::Args {
|
||||
@ -179,15 +185,7 @@ mod test {
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_init_error_score() {
|
||||
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 {}),
|
||||
]);
|
||||
let maestro = init_test_maestro();
|
||||
|
||||
let res = crate::init(
|
||||
maestro,
|
||||
@ -207,15 +205,7 @@ mod test {
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_init_number_score() {
|
||||
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 {}),
|
||||
]);
|
||||
let maestro = init_test_maestro();
|
||||
|
||||
let res = crate::init(
|
||||
maestro,
|
||||
@ -235,15 +225,7 @@ mod test {
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_filter_fn_all() {
|
||||
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 {}),
|
||||
]);
|
||||
let maestro = init_test_maestro();
|
||||
|
||||
let res = crate::maestro_scores_filter(&maestro, true, None, 0);
|
||||
|
||||
@ -252,15 +234,7 @@ mod test {
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_filter_fn_all_success() {
|
||||
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 {}),
|
||||
]);
|
||||
let maestro = init_test_maestro();
|
||||
|
||||
let res = crate::maestro_scores_filter(&maestro, true, Some("Success".to_owned()), 0);
|
||||
|
||||
@ -276,15 +250,7 @@ mod test {
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_filter_fn_all_error() {
|
||||
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 {}),
|
||||
]);
|
||||
let maestro = init_test_maestro();
|
||||
|
||||
let res = crate::maestro_scores_filter(&maestro, true, Some("Error".to_owned()), 0);
|
||||
|
||||
@ -300,15 +266,7 @@ mod test {
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_filter_fn_all_score() {
|
||||
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 {}),
|
||||
]);
|
||||
let maestro = init_test_maestro();
|
||||
|
||||
let res = crate::maestro_scores_filter(&maestro, true, Some("Score".to_owned()), 0);
|
||||
|
||||
@ -330,15 +288,7 @@ mod test {
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_filter_fn_number() {
|
||||
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 {}),
|
||||
]);
|
||||
let maestro = init_test_maestro();
|
||||
|
||||
let res = crate::maestro_scores_filter(&maestro, false, None, 0);
|
||||
|
||||
@ -356,15 +306,7 @@ mod test {
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_filter_fn_number_invalid() {
|
||||
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 {}),
|
||||
]);
|
||||
let maestro = init_test_maestro();
|
||||
|
||||
let res = crate::maestro_scores_filter(&maestro, false, None, 11);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user