|
@ -169,7 +169,7 @@ impl< |
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
#[cfg(test)]
|
|
|
mod test {
|
|
|
mod test {
|
|
|
use super::SymbolRunner;
|
|
|
|
|
|
|
|
|
use super::symbol_runner::TestSymbolRunner;
|
|
|
use crate::async_utils::run;
|
|
|
use crate::async_utils::run;
|
|
|
use crate::loggers::{Entry, StoringLogger};
|
|
|
use crate::loggers::{Entry, StoringLogger};
|
|
|
use crate::resources::{FromArtifact, FromResource, Resource};
|
|
|
use crate::resources::{FromArtifact, FromResource, Resource};
|
|
@ -178,33 +178,11 @@ mod test { |
|
|
use crate::{ImplementationBuilder, ResourceLocator, Setup};
|
|
|
use crate::{ImplementationBuilder, ResourceLocator, Setup};
|
|
|
use async_trait::async_trait;
|
|
|
use async_trait::async_trait;
|
|
|
use regex::Regex;
|
|
|
use regex::Regex;
|
|
|
use slog::{info, Logger};
|
|
|
|
|
|
use std::cell::RefCell;
|
|
|
use std::cell::RefCell;
|
|
|
use std::error::Error;
|
|
|
use std::error::Error;
|
|
|
use std::fmt::Debug;
|
|
|
use std::fmt::Debug;
|
|
|
use std::rc::{Rc, Weak};
|
|
|
use std::rc::{Rc, Weak};
|
|
|
|
|
|
|
|
|
struct TestSymbolRunner {
|
|
|
|
|
|
count: Rc<RefCell<usize>>,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[async_trait(?Send)]
|
|
|
|
|
|
impl SymbolRunner for TestSymbolRunner {
|
|
|
|
|
|
async fn run_symbol<S: Symbol + Debug>(
|
|
|
|
|
|
&self,
|
|
|
|
|
|
symbol: &S,
|
|
|
|
|
|
logger: &Logger,
|
|
|
|
|
|
force: bool,
|
|
|
|
|
|
) -> Result<bool, Box<dyn Error>> {
|
|
|
|
|
|
info!(logger, "run");
|
|
|
|
|
|
let run = force || !symbol.target_reached().await?;
|
|
|
|
|
|
if run {
|
|
|
|
|
|
*self.count.borrow_mut() += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
Ok(run)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
|
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
|
|
struct TestResource<T>(&'static str, T);
|
|
|
struct TestResource<T>(&'static str, T);
|
|
|
impl<T> Resource for TestResource<T> {
|
|
|
impl<T> Resource for TestResource<T> {
|
|
@ -308,10 +286,7 @@ mod test { |
|
|
>,
|
|
|
>,
|
|
|
StoringLogger,
|
|
|
StoringLogger,
|
|
|
) {
|
|
|
) {
|
|
|
let count = Rc::new(RefCell::new(0));
|
|
|
|
|
|
let runner = TestSymbolRunner {
|
|
|
|
|
|
count: Rc::clone(&count),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
let (count, runner) = TestSymbolRunner::new();
|
|
|
let logger = StoringLogger::new();
|
|
|
let logger = StoringLogger::new();
|
|
|
(count, Setup::new_with(runner, logger.clone()), logger)
|
|
|
(count, Setup::new_with(runner, logger.clone()), logger)
|
|
|
}
|
|
|
}
|
|
|