Skip to main content

vortex_edition/
test_harness.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4//! Test harness for edition declarations.
5//!
6//! Each edition definition should call [`validate_edition`] once from its `#[cfg(test)]`
7//! module, so every declared edition has a test proving its constraints hold.
8
9use vortex_error::VortexResult;
10use vortex_error::vortex_bail;
11
12use crate::EditionId;
13use crate::EditionSession;
14
15/// Validate one edition's constraints: its identifier is well-formed, it is declared in the
16/// given session, and the session's declarations as a whole validate (chronology, version
17/// forms, membership constraints).
18///
19/// ```ignore
20/// #[cfg(test)]
21/// mod tests {
22///     #[test]
23///     fn edition_is_valid() -> vortex_error::VortexResult<()> {
24///         vortex_edition::test_harness::validate_edition(&edition_session(), &CORE_2026_01_0)
25///     }
26/// }
27/// ```
28pub fn validate_edition(editions: &EditionSession, edition: &EditionId) -> VortexResult<()> {
29    edition.validate()?;
30    if editions.find(edition).is_none() {
31        vortex_bail!("{edition} is not declared in the session");
32    }
33    editions.validate()
34}