in crates/core/src/timeline/selector.rs [477:523]
fn test_try_create_instant() {
let selector = create_test_selector(&[Action::Commit], &[State::Completed], None, None);
assert!(
selector.try_create_instant("20240103153030999").is_err(),
"Should fail to create instant as file name is invalid"
);
let instant_file_name = "20240103153030999.commit";
let selector = create_test_selector(&[Action::Commit], &[State::Completed], None, None);
assert!(selector.try_create_instant(instant_file_name).is_ok());
let selector = create_test_selector(&[Action::Commit], &[State::Requested], None, None);
assert!(
selector.try_create_instant(instant_file_name).is_err(),
"Should fail to create instant as state is different"
);
let selector =
create_test_selector(&[Action::ReplaceCommit], &[State::Completed], None, None);
assert!(
selector.try_create_instant(instant_file_name).is_err(),
"Should fail to create instant as action is different"
);
let selector = create_test_selector(
&[Action::Commit],
&[State::Completed],
Instant::parse_datetime("20240103153031", "UTC").ok(),
None,
);
assert!(
selector.try_create_instant(instant_file_name).is_err(),
"Should fail to create instant as timestamp is before start"
);
let selector = create_test_selector(
&[Action::Commit],
&[State::Completed],
None,
Instant::parse_datetime("20240103153030999", "UTC").ok(),
);
assert!(
selector.try_create_instant(instant_file_name).is_err(),
"Should fail to create instant as timestamp is at the end timestamp (exclusive)"
);
}