use std::time::Duration;
use integra8_components::{
ComponentDescription, ComponentId, ComponentLocation, ConcurrencyMode, Delegate,
SuiteAttributes, Test, TestParameters,
};
#[derive(Debug)]
pub struct TestAttributesDecoration {
pub name: Option<&'static str>,
pub description: Option<&'static str>,
pub location: ComponentLocation,
pub allow_fail: Option<bool>,
pub ignore: Option<bool>,
pub warning_time_limit: Option<Duration>,
pub time_limit: Option<Duration>,
pub concurrency_mode: Option<ConcurrencyMode>,
}
#[derive(Debug)]
pub struct TestDecoration<TParameters> {
pub desc: TestAttributesDecoration,
pub test_fn: Delegate<TParameters>,
}
impl<TParameters: TestParameters> TestDecoration<TParameters> {
pub fn into_component(
self,
id: ComponentId,
parent_description: &ComponentDescription,
parent_attributes: &SuiteAttributes,
parameters: &TParameters,
) -> Test<TParameters> {
Test::new(
parent_description,
parent_attributes,
parameters,
id,
self.desc.name,
self.desc.description,
self.desc.location,
self.desc.ignore,
self.desc.allow_fail,
self.desc.warning_time_limit,
self.desc.time_limit,
self.desc.concurrency_mode,
self.test_fn,
)
}
}