Skip to main content

reifydb_flow/factory/
coord.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2026 ReifyDB
3
4use reifydb_value::factory::time::at_millis;
5
6use crate::window::coord::EventCoord;
7
8pub fn event_coord_at_millis(value: u64) -> EventCoord {
9	EventCoord::of(&at_millis(value))
10}
11
12#[cfg(test)]
13mod tests {
14	use reifydb_value::factory::time::at_nanos;
15
16	use super::*;
17
18	#[test]
19	fn the_coordinate_is_the_instant_its_name_promises() {
20		// `EventCoord` hides the instant behind an opaque wrapper, so a caller cannot see which unit
21		// the integer was read as. Rewriting the body to `at_nanos` would leave every windowing test
22		// that builds fixtures through this helper green while moving every coordinate it produces by
23		// a factor of a million, so pin it against the value-crate factory of the same name.
24		assert_eq!(event_coord_at_millis(1_000).at(), at_millis(1_000));
25		assert_ne!(event_coord_at_millis(1_000).at(), at_nanos(1_000));
26	}
27
28	#[test]
29	fn the_coordinate_is_the_instant_itself_and_not_a_floored_one() {
30		// Sliding and session assignment compare a coordinate against a span boundary, so a helper
31		// that quietly floored its argument would make every off-boundary fixture land on a boundary
32		// and hide exactly the assignment errors those tests exist to catch.
33		assert_eq!(event_coord_at_millis(1_337).at(), at_millis(1_337));
34		assert!(event_coord_at_millis(999) < event_coord_at_millis(1_000));
35	}
36}