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 crate::EditionError;
10use crate::EditionId;
11use crate::EditionSession;
12
13/// Validate one edition's constraints: its identifier is well-formed, it is declared in the
14/// given session, and the session's declarations as a whole validate (chronology, version
15/// forms, membership constraints).
16///
17/// ```ignore
18/// #[cfg(test)]
19/// mod tests {
20///     #[test]
21///     fn edition_is_valid() -> Result<(), vortex_edition::EditionError> {
22///         vortex_edition::test_harness::validate_edition(&edition_session(), &CORE_2026_01_0)
23///     }
24/// }
25/// ```
26pub fn validate_edition(
27    editions: &EditionSession,
28    edition: &EditionId,
29) -> Result<(), EditionError> {
30    edition.validate()?;
31    if editions.find(edition).is_none() {
32        return Err(EditionError::new(format!(
33            "{edition} is not declared in the session"
34        )));
35    }
36    editions.validate()
37}