Skip to content

Commit be569c2

Browse files
committed
input/process.rs: Check actual error messages in tests
1 parent 05ef551 commit be569c2

1 file changed

Lines changed: 22 additions & 13 deletions

File tree

src/input/process.rs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ fn validate_svd_commodity(
275275
mod tests {
276276
use super::*;
277277
use crate::commodity::{CommodityLevyMap, DemandMap};
278-
use crate::fixture::{time_slice, time_slice_info};
278+
use crate::fixture::{assert_error, time_slice, time_slice_info};
279279
use crate::process::{FlowType, ProcessFlow};
280280
use crate::time_slice::{TimeSliceID, TimeSliceLevel};
281281
use indexmap::indexmap;
@@ -340,14 +340,20 @@ mod tests {
340340
) {
341341
// Invalid scenario: no producer
342342
let flows = HashMap::from_iter(vec![("process1".into(), input_flows_sed.clone())]);
343-
assert!(validate_sed_commodity(&commodity_sed.id, &flows, &"GBR".into(), 2010).is_err());
343+
assert_error!(
344+
validate_sed_commodity(&commodity_sed.id, &flows, &"GBR".into(), 2010),
345+
"Commodity commodity_sed of 'SED' type must have both producer and consumer processes for region GBR in year 2010"
346+
);
344347
}
345348

346349
#[rstest]
347350
fn test_validate_sed_commodity(commodity_sed: Commodity, output_flows_sed: ProcessFlowsMap) {
348351
// Invalid scenario: no consumer
349352
let flows = HashMap::from_iter(vec![("process2".into(), output_flows_sed.clone())]);
350-
assert!(validate_sed_commodity(&commodity_sed.id, &flows, &"GBR".into(), 2010).is_err());
353+
assert_error!(
354+
validate_sed_commodity(&commodity_sed.id, &flows, &"GBR".into(), 2010),
355+
"Commodity commodity_sed of 'SED' type must have both producer and consumer processes for region GBR in year 2010"
356+
);
351357
}
352358

353359
#[fixture]
@@ -423,15 +429,18 @@ mod tests {
423429
0.0..=0.0,
424430
)]),
425431
)]);
426-
assert!(validate_svd_commodity(
427-
&time_slice_info,
428-
&commodity_svd,
429-
&flows_svd,
430-
&availabilities,
431-
&"GBR".into(),
432-
2010,
433-
&time_slice.into()
434-
)
435-
.is_err());
432+
assert_error!(
433+
validate_svd_commodity(
434+
&time_slice_info,
435+
&commodity_svd,
436+
&flows_svd,
437+
&availabilities,
438+
&"GBR".into(),
439+
2010,
440+
&time_slice.into()
441+
),
442+
"Commodity commodity_svd of 'SVD' type must have a producer process \
443+
for region GBR in year 2010 and time slice(s) winter.day"
444+
);
436445
}
437446
}

0 commit comments

Comments
 (0)