From dbe672e1bc5c3849a8ff7d80a4e9e5d1b4ed631b Mon Sep 17 00:00:00 2001 From: mimir-d Date: Sat, 12 Oct 2024 14:39:27 +0100 Subject: [PATCH] remove the boilerplate needed for tv::Value - this commit adds template args such that the users dont need to manually covert their values into `tv::Value` - applies for measurements, metadata and run start params Signed-off-by: mimir-d --- examples/file.rs | 4 +- examples/measurement_series.rs | 50 ++++++-------- examples/measurement_single.rs | 8 +-- examples/measurement_subcomponent.rs | 4 +- examples/measurement_validators.rs | 12 ++-- src/output/dut.rs | 8 +-- src/output/file.rs | 12 ++-- src/output/log.rs | 2 + src/output/measure.rs | 100 ++++++++++++++------------- src/output/run.rs | 14 ++-- src/output/step.rs | 16 ++--- tests/output/file.rs | 2 +- tests/output/measure.rs | 48 ++++++------- tests/output/run.rs | 8 +-- 14 files changed, 141 insertions(+), 147 deletions(-) diff --git a/examples/file.rs b/examples/file.rs index 4ee475e..9b29ca1 100644 --- a/examples/file.rs +++ b/examples/file.rs @@ -26,9 +26,7 @@ async fn main() -> Result<()> { tv::TestRun::builder("simple measurement", "1.0") .build() .scope(dut, |r| async move { - r.add_step("step0") - .scope(run_file_step) - .await?; + r.add_step("step0").scope(run_file_step).await?; Ok(tv::TestRunOutcome { status: TestStatus::Complete, diff --git a/examples/measurement_series.rs b/examples/measurement_series.rs index 7a325b9..c707148 100644 --- a/examples/measurement_series.rs +++ b/examples/measurement_series.rs @@ -21,9 +21,9 @@ async fn step0_measurements(step: tv::ScopedTestStep) -> Result Result Result Result<()> { tv::TestRun::builder("simple measurement", "1.0") .build() .scope(dut, |r| async move { - r.add_step("step0") - .scope(step0_measurements) - .await?; + r.add_step("step0").scope(step0_measurements).await?; - r.add_step("step1") - .scope(step1_measurements) - .await?; + r.add_step("step1").scope(step1_measurements).await?; - r.add_step("step2") - .scope(step2_measurements) - .await?; + r.add_step("step2").scope(step2_measurements).await?; Ok(tv::TestRunOutcome { status: TestStatus::Complete, diff --git a/examples/measurement_single.rs b/examples/measurement_single.rs index c39b984..41c2f7e 100644 --- a/examples/measurement_single.rs +++ b/examples/measurement_single.rs @@ -10,9 +10,9 @@ use ocptv::output as tv; use tv::{TestResult, TestStatus}; async fn run_measure_step(step: tv::ScopedTestStep) -> Result { - step.add_measurement("temperature", 42.5.into()).await?; + step.add_measurement("temperature", 42.5).await?; step.add_measurement_detail( - tv::Measurement::builder("fan_speed", 1200.into()) + tv::Measurement::builder("fan_speed", 1200) .unit("rpm") .build(), ) @@ -29,9 +29,7 @@ async fn main() -> Result<()> { tv::TestRun::builder("simple measurement", "1.0") .build() .scope(dut, |r| async move { - r.add_step("step0") - .scope(run_measure_step) - .await?; + r.add_step("step0").scope(run_measure_step).await?; Ok(tv::TestRunOutcome { status: TestStatus::Complete, diff --git a/examples/measurement_subcomponent.rs b/examples/measurement_subcomponent.rs index 755547a..d9a3d87 100644 --- a/examples/measurement_subcomponent.rs +++ b/examples/measurement_subcomponent.rs @@ -15,7 +15,7 @@ async fn run_measure_step( ram0: tv::DutHardwareInfo, ) -> Result { step.add_measurement_detail( - tv::Measurement::builder("temp0", 100.5.into()) + tv::Measurement::builder("temp0", 100.5) .unit("F") .hardware_info(&ram0) .subcomponent(tv::Subcomponent::builder("chip0").build()) @@ -40,7 +40,7 @@ async fn run_measure_step( chip1_temp .scope(|s| async move { - s.add_measurement(79.into()).await?; + s.add_measurement(79).await?; Ok(()) }) diff --git a/examples/measurement_validators.rs b/examples/measurement_validators.rs index f8655cd..23650f4 100644 --- a/examples/measurement_validators.rs +++ b/examples/measurement_validators.rs @@ -12,9 +12,9 @@ use tv::{TestResult, TestStatus, ValidatorType}; async fn run_measure_step(step: tv::ScopedTestStep) -> Result { step.add_measurement_detail( - tv::Measurement::builder("temp", 40.into()) + tv::Measurement::builder("temp", 40) .add_validator( - tv::Validator::builder(ValidatorType::GreaterThan, 30.into()) + tv::Validator::builder(ValidatorType::GreaterThan, 30) .name("gt_30") .build(), ) @@ -25,20 +25,18 @@ async fn run_measure_step(step: tv::ScopedTestStep) -> Result Self { - self.metadata.insert(key.to_string(), value); + pub fn add_metadata>(mut self, key: &str, value: V) -> Self { + self.metadata.insert(key.to_string(), value.into()); self } @@ -518,8 +518,8 @@ mod tests { fn test_dut_builder() -> Result<()> { let mut dut = DutInfo::builder("1234") .name("dut") - .add_metadata("key", "value".into()) - .add_metadata("key2", "value2".into()) + .add_metadata("key", "value") + .add_metadata("key2", "value2") .add_platform_info(PlatformInfo::builder("platform_info").build()) .build(); diff --git a/src/output/file.rs b/src/output/file.rs index dab09f7..8c72dea 100644 --- a/src/output/file.rs +++ b/src/output/file.rs @@ -35,7 +35,7 @@ use crate::spec; /// .is_snapshot(true) /// .description("description") /// .content_type(mime::TEXT_PLAIN) -/// .add_metadata("key", "value".into()) +/// .add_metadata("key", "value") /// .build(); /// ``` pub struct File { @@ -79,7 +79,7 @@ impl File { /// let file = File::builder("name", uri) /// .description("description") /// .content_type(mime::TEXT_PLAIN) - /// .add_metadata("key", "value".into()) + /// .add_metadata("key", "value") /// .build(); /// ``` pub fn builder(name: &str, uri: tv::Uri) -> FileBuilder { @@ -119,7 +119,7 @@ impl File { /// let builder = File::builder("name", uri) /// .description("description") /// .content_type(mime::TEXT_PLAIN) -/// .add_metadata("key", "value".into()); +/// .add_metadata("key", "value"); /// let file = builder.build(); /// ``` pub struct FileBuilder { @@ -199,10 +199,10 @@ impl FileBuilder { /// /// let uri = Uri::parse("file:///tmp/foo").unwrap(); /// let builder = File::builder("name", uri) - /// .add_metadata("key", "value".into()); + /// .add_metadata("key", "value"); /// ``` - pub fn add_metadata(mut self, key: &str, value: tv::Value) -> FileBuilder { - self.metadata.insert(key.to_string(), value); + pub fn add_metadata>(mut self, key: &str, value: V) -> FileBuilder { + self.metadata.insert(key.to_string(), value.into()); self } diff --git a/src/output/log.rs b/src/output/log.rs index f39ad90..b5e933a 100644 --- a/src/output/log.rs +++ b/src/output/log.rs @@ -43,10 +43,12 @@ impl LogBuilder { source_location: None, } } + pub fn severity(mut self, value: spec::LogSeverity) -> Self { self.severity = value; self } + pub fn source(mut self, file: &str, line: i32) -> Self { self.source_location = Some(spec::SourceLocation { file: file.to_string(), diff --git a/src/output/measure.rs b/src/output/measure.rs index f397a01..030a323 100644 --- a/src/output/measure.rs +++ b/src/output/measure.rs @@ -107,9 +107,9 @@ impl MeasurementSeries { /// let series = step.add_measurement_series("name"); /// series.scope(|s| { /// async move { - /// s.add_measurement(60.into()).await?; - /// s.add_measurement(70.into()).await?; - /// s.add_measurement(80.into()).await?; + /// s.add_measurement(60).await?; + /// s.add_measurement(70).await?; + /// s.add_measurement(80).await?; /// Ok(()) /// }.boxed() /// }).await?; @@ -198,14 +198,17 @@ impl StartedMeasurementSeries { /// let step = run.add_step("step_name").start().await?; /// /// let series = step.add_measurement_series("name").start().await?; - /// series.add_measurement(60.into()).await?; + /// series.add_measurement(60).await?; /// /// # Ok::<(), OcptvError>(()) /// # }); /// ``` - pub async fn add_measurement(&self, value: tv::Value) -> Result<(), tv::OcptvError> { + pub async fn add_measurement>( + &self, + value: V, + ) -> Result<(), tv::OcptvError> { self.add_measurement_detail(MeasurementElementDetail { - value, + value: value.into(), ..Default::default() }) .await @@ -226,7 +229,7 @@ impl StartedMeasurementSeries { /// let step = run.add_step("step_name").start().await?; /// /// let series = step.add_measurement_series("name").start().await?; - /// let elem = MeasurementElementDetail::builder(60.into()).add_metadata("key", "value".into()).build(); + /// let elem = MeasurementElementDetail::builder(60).add_metadata("key", "value").build(); /// series.add_measurement_detail(elem).await?; /// /// # Ok::<(), OcptvError>(()) @@ -265,7 +268,7 @@ pub struct ScopedMeasurementSeries { impl ScopedMeasurementSeries { delegate! { to self.series { - pub async fn add_measurement(&self, value: tv::Value) -> Result<(), tv::OcptvError>; + pub async fn add_measurement>(&self, value: V) -> Result<(), tv::OcptvError>; pub async fn add_measurement_detail( &self, element: MeasurementElementDetail, @@ -284,8 +287,8 @@ pub struct MeasurementElementDetail { } impl MeasurementElementDetail { - pub fn builder(value: tv::Value) -> MeasurementElementDetailBuilder { - MeasurementElementDetailBuilder::new(value) + pub fn builder>(value: V) -> MeasurementElementDetailBuilder { + MeasurementElementDetailBuilder::new(value.into()) } } @@ -311,8 +314,8 @@ impl MeasurementElementDetailBuilder { self } - pub fn add_metadata(mut self, key: &str, value: tv::Value) -> Self { - self.metadata.insert(key.to_string(), value); + pub fn add_metadata>(mut self, key: &str, value: V) -> Self { + self.metadata.insert(key.to_string(), value.into()); self } @@ -335,8 +338,11 @@ pub struct Validator { } impl Validator { - pub fn builder(validator_type: spec::ValidatorType, value: tv::Value) -> ValidatorBuilder { - ValidatorBuilder::new(validator_type, value) + pub fn builder>( + validator_type: spec::ValidatorType, + value: V, + ) -> ValidatorBuilder { + ValidatorBuilder::new(validator_type, value.into()) } pub fn to_spec(&self) -> spec::Validator { @@ -374,8 +380,8 @@ impl ValidatorBuilder { self } - pub fn add_metadata(mut self, key: &str, value: tv::Value) -> Self { - self.metadata.insert(key.to_string(), value); + pub fn add_metadata>(mut self, key: &str, value: V) -> Self { + self.metadata.insert(key.to_string(), value.into()); self } @@ -398,7 +404,7 @@ impl ValidatorBuilder { /// /// ``` /// # use ocptv::output::*; -/// let measurement = Measurement::new("name", 50.into()); +/// let measurement = Measurement::new("name", 50); /// ``` /// /// ## Create a Measurement object with the `builder` method @@ -408,9 +414,9 @@ impl ValidatorBuilder { /// let mut dut = DutInfo::new("dut0"); /// let hw_info = dut.add_hardware_info(HardwareInfo::builder("name").build()); /// -/// let measurement = Measurement::builder("name", 50.into()) -/// .add_validator(Validator::builder(ValidatorType::Equal, 30.into()).build()) -/// .add_metadata("key", "value".into()) +/// let measurement = Measurement::builder("name", 50) +/// .add_validator(Validator::builder(ValidatorType::Equal, 30).build()) +/// .add_metadata("key", "value") /// .hardware_info(&hw_info) /// .subcomponent(Subcomponent::builder("name").build()) /// .build(); @@ -436,12 +442,12 @@ impl Measurement { /// /// ``` /// # use ocptv::output::*; - /// let measurement = Measurement::new("name", 50.into()); + /// let measurement = Measurement::new("name", 50); /// ``` - pub fn new(name: &str, value: tv::Value) -> Self { + pub fn new>(name: &str, value: V) -> Self { Measurement { name: name.to_string(), - value, + value: value.into(), ..Default::default() } } @@ -456,15 +462,15 @@ impl Measurement { /// let mut dut = DutInfo::new("dut0"); /// let hw_info = dut.add_hardware_info(HardwareInfo::builder("name").build()); /// - /// let measurement = Measurement::builder("name", 50.into()) - /// .add_validator(Validator::builder(ValidatorType::Equal, 30.into()).build()) - /// .add_metadata("key", "value".into()) + /// let measurement = Measurement::builder("name", 50) + /// .add_validator(Validator::builder(ValidatorType::Equal, 30).build()) + /// .add_metadata("key", "value") /// .hardware_info(&hw_info) /// .subcomponent(Subcomponent::builder("name").build()) /// .build(); /// ``` - pub fn builder(name: &str, value: tv::Value) -> MeasurementBuilder { - MeasurementBuilder::new(name, value) + pub fn builder>(name: &str, value: V) -> MeasurementBuilder { + MeasurementBuilder::new(name, value.into()) } /// Creates an artifact from a Measurement object. @@ -473,7 +479,7 @@ impl Measurement { /// /// ``` /// # use ocptv::output::*; - /// let measurement = Measurement::new("name", 50.into()); + /// let measurement = Measurement::new("name", 50); /// let _ = measurement.to_artifact(); /// ``` pub fn to_artifact(&self) -> spec::Measurement { @@ -504,9 +510,9 @@ impl Measurement { /// let mut dut = DutInfo::new("dut0"); /// let hw_info = dut.add_hardware_info(HardwareInfo::builder("name").build()); /// -/// let builder = Measurement::builder("name", 50.into()) -/// .add_validator(Validator::builder(ValidatorType::Equal, 30.into()).build()) -/// .add_metadata("key", "value".into()) +/// let builder = Measurement::builder("name", 50) +/// .add_validator(Validator::builder(ValidatorType::Equal, 30).build()) +/// .add_metadata("key", "value") /// .hardware_info(&hw_info) /// .subcomponent(Subcomponent::builder("name").build()); /// let measurement = builder.build(); @@ -540,8 +546,8 @@ impl MeasurementBuilder { /// /// ``` /// # use ocptv::output::*; - /// let builder = Measurement::builder("name", 50.into()) - /// .add_validator(Validator::builder(ValidatorType::Equal, 30.into()).build()); + /// let builder = Measurement::builder("name", 50) + /// .add_validator(Validator::builder(ValidatorType::Equal, 30).build()); /// ``` pub fn add_validator(mut self, validator: Validator) -> Self { self.validators.push(validator.clone()); @@ -557,7 +563,7 @@ impl MeasurementBuilder { /// let mut dut = DutInfo::new("dut0"); /// let hw_info = dut.add_hardware_info(HardwareInfo::builder("name").build()); /// - /// let builder = Measurement::builder("name", 50.into()) + /// let builder = Measurement::builder("name", 50) /// .hardware_info(&hw_info); /// ``` pub fn hardware_info(mut self, hardware_info: &dut::DutHardwareInfo) -> Self { @@ -571,7 +577,7 @@ impl MeasurementBuilder { /// /// ``` /// # use ocptv::output::*; - /// let builder = Measurement::builder("name", 50.into()) + /// let builder = Measurement::builder("name", 50) /// .subcomponent(Subcomponent::builder("name").build()); /// ``` pub fn subcomponent(mut self, subcomponent: dut::Subcomponent) -> Self { @@ -586,10 +592,10 @@ impl MeasurementBuilder { /// ``` /// # use ocptv::output::*; /// let builder = - /// Measurement::builder("name", 50.into()).add_metadata("key", "value".into()); + /// Measurement::builder("name", 50).add_metadata("key", "value"); /// ``` - pub fn add_metadata(mut self, key: &str, value: tv::Value) -> Self { - self.metadata.insert(key.to_string(), value); + pub fn add_metadata>(mut self, key: &str, value: V) -> Self { + self.metadata.insert(key.to_string(), value.into()); self } @@ -599,7 +605,7 @@ impl MeasurementBuilder { /// /// ``` /// # use ocptv::output::*; - /// let builder = Measurement::builder("name", 50000.into()).unit("RPM"); + /// let builder = Measurement::builder("name", 50000).unit("RPM"); /// ``` pub fn unit(mut self, unit: &str) -> MeasurementBuilder { self.unit = Some(unit.to_string()); @@ -612,7 +618,7 @@ impl MeasurementBuilder { /// /// ``` /// # use ocptv::output::*; - /// let builder = Measurement::builder("name", 50.into()); + /// let builder = Measurement::builder("name", 50); /// let measurement = builder.build(); /// ``` pub fn build(self) -> Measurement { @@ -703,8 +709,8 @@ impl MeasurementSeriesDetailBuilder { self } - pub fn add_metadata(mut self, key: &str, value: tv::Value) -> Self { - self.metadata.insert(key.to_string(), value); + pub fn add_metadata>(mut self, key: &str, value: V) -> Self { + self.metadata.insert(key.to_string(), value.into()); self } @@ -762,7 +768,7 @@ mod tests { let name = "name".to_owned(); let value = tv::Value::from(50000); let hw_info = dut.add_hardware_info(HardwareInfo::builder("name").build()); - let validator = Validator::builder(spec::ValidatorType::Equal, 30.into()).build(); + let validator = Validator::builder(spec::ValidatorType::Equal, 30).build(); let meta_key = "key"; let meta_value = tv::Value::from("value"); @@ -801,10 +807,10 @@ mod tests { #[test] fn test_validator() -> Result<()> { - let validator = Validator::builder(ValidatorType::Equal, 30.into()) + let validator = Validator::builder(ValidatorType::Equal, 30) .name("validator") - .add_metadata("key", "value".into()) - .add_metadata("key2", "value2".into()) + .add_metadata("key", "value") + .add_metadata("key2", "value2") .build(); let spec_validator = validator.to_spec(); diff --git a/src/output/run.rs b/src/output/run.rs index 4bd0f41..596be44 100644 --- a/src/output/run.rs +++ b/src/output/run.rs @@ -102,7 +102,7 @@ impl TestRun { } /// Builds a scope in the [`TestRun`] object, taking care of starting and - /// ending it. View [`TestRun::start`] and [`TestRun::end`] methods. + /// ending it. View [`TestRun::start`] and [`StartedTestRun::end`] methods. /// After the scope is constructed, additional objects may be added to it. /// This is the preferred usage for the [`TestRun`], since it guarantees /// all the messages are emitted between the start and end messages, the order @@ -218,11 +218,11 @@ impl TestRunBuilder { /// ```rust /// # use ocptv::output::*; /// let run = TestRun::builder("run_name", "1.0") - /// .add_parameter("param1", "value1".into()) + /// .add_parameter("param1", "value1") /// .build(); /// ``` - pub fn add_parameter(mut self, key: &str, value: tv::Value) -> Self { - self.parameters.insert(key.to_string(), value); + pub fn add_parameter>(mut self, key: &str, value: V) -> Self { + self.parameters.insert(key.to_string(), value.into()); self } @@ -265,11 +265,11 @@ impl TestRunBuilder { /// # use ocptv::output::*; /// /// let run = TestRun::builder("run_name", "1.0") - /// .add_metadata("meta1", "value1".into()) + /// .add_metadata("meta1", "value1") /// .build(); /// ``` - pub fn add_metadata(mut self, key: &str, value: tv::Value) -> Self { - self.metadata.insert(key.to_string(), value); + pub fn add_metadata>(mut self, key: &str, value: V) -> Self { + self.metadata.insert(key.to_string(), value.into()); self } diff --git a/src/output/step.rs b/src/output/step.rs index 67c322a..b9d4cba 100644 --- a/src/output/step.rs +++ b/src/output/step.rs @@ -389,16 +389,16 @@ impl StartedTestStep { /// let run = TestRun::new("diagnostic_name", "1.0").start(dut).await?; /// /// let step = run.add_step("step_name").start().await?; - /// step.add_measurement("name", 50.into()).await?; + /// step.add_measurement("name", 50).await?; /// step.end(TestStatus::Complete).await?; /// /// # Ok::<(), OcptvError>(()) /// # }); /// ``` - pub async fn add_measurement( + pub async fn add_measurement>( &self, name: &str, - value: tv::Value, + value: V, ) -> Result<(), tv::OcptvError> { let measurement = measure::Measurement::new(name, value); @@ -427,9 +427,9 @@ impl StartedTestStep { /// let run = TestRun::builder("diagnostic_name", "1.0").build().start(dut).await?; /// let step = run.add_step("step_name").start().await?; /// - /// let measurement = Measurement::builder("name", 5000.into()) - /// .add_validator(Validator::builder(ValidatorType::Equal, 30.into()).build()) - /// .add_metadata("key", "value".into()) + /// let measurement = Measurement::builder("name", 5000) + /// .add_validator(Validator::builder(ValidatorType::Equal, 30).build()) + /// .add_metadata("key", "value") /// .hardware_info(&hw_info) /// .subcomponent(Subcomponent::builder("name").build()) /// .build(); @@ -642,7 +642,7 @@ impl StartedTestStep { /// let file = File::builder("name", uri) /// .description("description") /// .content_type(mime::TEXT_PLAIN) - /// .add_metadata("key", "value".into()) + /// .add_metadata("key", "value") /// .build(); /// step.add_file_detail(file).await?; /// step.end(TestStatus::Complete).await?; @@ -710,7 +710,7 @@ impl ScopedTestStep { pub async fn add_error_msg(&self, symptom: &str, msg: &str) -> Result<(), tv::OcptvError>; pub async fn add_error_detail(&self, error: error::Error) -> Result<(), tv::OcptvError>; - pub async fn add_measurement(&self, name: &str, value: tv::Value) -> Result<(), tv::OcptvError>; + pub async fn add_measurement>(&self, name: &str, value: V) -> Result<(), tv::OcptvError>; pub async fn add_measurement_detail(&self, detail: measure::Measurement) -> Result<(), tv::OcptvError>; pub fn add_measurement_series(&self, name: &str) -> tv::MeasurementSeries; diff --git a/tests/output/file.rs b/tests/output/file.rs index bc0ce98..abab281 100644 --- a/tests/output/file.rs +++ b/tests/output/file.rs @@ -74,7 +74,7 @@ async fn test_step_with_file_builder() -> Result<()> { let file = File::builder("name", uri) .content_type(mime::TEXT_PLAIN) .description("description") - .add_metadata("key", "value".into()) + .add_metadata("key", "value") .build(); s.add_file_detail(file).await?; diff --git a/tests/output/measure.rs b/tests/output/measure.rs index e3da99b..371c16c 100644 --- a/tests/output/measure.rs +++ b/tests/output/measure.rs @@ -36,7 +36,7 @@ async fn test_step_with_measurement() -> Result<()> { ]; check_output_step(&expected, |s, _| async move { - s.add_measurement("name", 50.into()).await?; + s.add_measurement("name", 50).await?; Ok(()) }) @@ -80,10 +80,10 @@ async fn test_step_with_measurement_builder() -> Result<()> { async move { let hw_info = dut.hardware_info("hw0").unwrap(); // must exist - let measurement = Measurement::builder("name", 50.into()) - .add_validator(Validator::builder(ValidatorType::Equal, 30.into()).build()) - .add_metadata("key", "value".into()) - .add_metadata("key2", "value2".into()) + let measurement = Measurement::builder("name", 50) + .add_validator(Validator::builder(ValidatorType::Equal, 30).build()) + .add_metadata("key", "value") + .add_metadata("key2", "value2") .hardware_info(hw_info) .subcomponent(Subcomponent::builder("name").build()) .build(); @@ -256,9 +256,9 @@ async fn test_step_with_measurement_series_with_details() -> Result<()> { MeasurementSeriesDetail::builder("name") .id(Ident::Exact("series_id".to_owned())) .unit("unit") - .add_metadata("key", "value".into()) - .add_metadata("key2", "value2".into()) - .add_validator(Validator::builder(ValidatorType::Equal, 30.into()).build()) + .add_metadata("key", "value") + .add_metadata("key2", "value2") + .add_validator(Validator::builder(ValidatorType::Equal, 30).build()) .hardware_info(hw_info) .subcomponent(Subcomponent::builder("name").build()) .build(), @@ -320,7 +320,7 @@ async fn test_step_with_measurement_series_element() -> Result<()> { check_output_step(&expected, |s, _| async move { let series = s.add_measurement_series("name").start().await?; - series.add_measurement(60.into()).await?; + series.add_measurement(60).await?; series.end().await?; Ok(()) @@ -403,9 +403,9 @@ async fn test_step_with_measurement_series_element_index_no() -> Result<()> { async move { let series = s.add_measurement_series("name").start().await?; // add more than one element to check the index increments correctly - series.add_measurement(60.into()).await?; - series.add_measurement(70.into()).await?; - series.add_measurement(80.into()).await?; + series.add_measurement(60).await?; + series.add_measurement(70).await?; + series.add_measurement(80).await?; series.end().await?; Ok(()) @@ -467,10 +467,10 @@ async fn test_step_with_measurement_series_element_with_details() -> Result<()> s.add_measurement_series("name") .scope(|s| async move { s.add_measurement_detail( - MeasurementElementDetail::builder(60.into()) + MeasurementElementDetail::builder(60) .timestamp(DATETIME.with_timezone(&chrono_tz::UTC)) - .add_metadata("key", "value".into()) - .add_metadata("key2", "value2".into()) + .add_metadata("key", "value") + .add_metadata("key2", "value2") .build(), ) .await?; @@ -564,22 +564,22 @@ async fn test_step_with_measurement_series_element_with_metadata_index_no() -> R // add more than one element to check the index increments correctly series .add_measurement_detail( - MeasurementElementDetail::builder(60.into()) - .add_metadata("key", "value".into()) + MeasurementElementDetail::builder(60) + .add_metadata("key", "value") .build(), ) .await?; series .add_measurement_detail( - MeasurementElementDetail::builder(70.into()) - .add_metadata("key2", "value2".into()) + MeasurementElementDetail::builder(70) + .add_metadata("key2", "value2") .build(), ) .await?; series .add_measurement_detail( - MeasurementElementDetail::builder(80.into()) - .add_metadata("key3", "value3".into()) + MeasurementElementDetail::builder(80) + .add_metadata("key3", "value3") .build(), ) .await?; @@ -666,9 +666,9 @@ async fn test_step_with_measurement_series_scope() -> Result<()> { let series = s.add_measurement_series("name"); series .scope(|s| async move { - s.add_measurement(60.into()).await?; - s.add_measurement(70.into()).await?; - s.add_measurement(80.into()).await?; + s.add_measurement(60).await?; + s.add_measurement(70).await?; + s.add_measurement(80).await?; Ok(()) }) diff --git a/tests/output/run.rs b/tests/output/run.rs index 3ca1677..c7e8af3 100644 --- a/tests/output/run.rs +++ b/tests/output/run.rs @@ -122,7 +122,7 @@ async fn test_testrun_metadata() -> Result<()> { check_output(&expected, |run_builder, dut| async { let run = run_builder - .add_metadata("key", "value".into()) + .add_metadata("key", "value") .build() .start(dut) .await?; @@ -174,9 +174,9 @@ async fn test_testrun_builder() -> Result<()> { check_output(&expected, |run_builder, dut| async { let run = run_builder - .add_metadata("key", "value".into()) - .add_metadata("key2", "value2".into()) - .add_parameter("key", "value".into()) + .add_metadata("key", "value") + .add_metadata("key2", "value2") + .add_parameter("key", "value") .command_line("cmd_line") .build() .start(dut)