summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/db')
-rw-r--r--src/db/mod.rs8
-rw-r--r--src/db/model/mod.rs6
-rw-r--r--src/db/model/state.rs31
3 files changed, 37 insertions, 8 deletions
diff --git a/src/db/mod.rs b/src/db/mod.rs
index 1266d9e..e8a97b4 100644
--- a/src/db/mod.rs
+++ b/src/db/mod.rs
@@ -36,11 +36,17 @@ pub(crate) use model::json_or;
pub use model::{
BUILD_STEPS, BuildState, CandidateRow, CandidateState,
- Identity, Recipe, ReleaseRow, ReleaseState,
+ Identity, Recipe, ReleaseRow,
SourceDigest, SourceEntry, StageBCacheRow, StepState,
SubscriptionState, UpstreamPin, WorldMember, candidate_kind,
notice_kind,
};
+/// `ReleaseState` is a column type on the release row. Nothing outside `db`
+/// names it, so the alias out of `db` exists only for the test tier.
+#[cfg(feature = "test-support")]
+pub use model::ReleaseState;
+#[cfg(not(feature = "test-support"))]
+pub(crate) use model::ReleaseState;
pub use audit::{AuditEntry, audit, audit_in, audit_system, list_audit};
pub use invariants::approved_but_unbuilt;
#[cfg(feature = "test-support")]
diff --git a/src/db/model/mod.rs b/src/db/model/mod.rs
index 827ce5e..ba97073 100644
--- a/src/db/model/mod.rs
+++ b/src/db/model/mod.rs
@@ -208,7 +208,11 @@ mod state;
pub(crate) use state::StateEnum;
pub use build_state::{BUILD_STEPS, BuildState, StepState};
-pub use state::{CandidateState, ReleaseState, SubscriptionState, candidate_kind, notice_kind};
+pub use state::{CandidateState, SubscriptionState, candidate_kind, notice_kind};
+#[cfg(feature = "test-support")]
+pub use state::ReleaseState;
+#[cfg(not(feature = "test-support"))]
+pub(crate) use state::ReleaseState;
#[cfg(test)]
mod tests {
diff --git a/src/db/model/state.rs b/src/db/model/state.rs
index f773f5b..dcc9b84 100644
--- a/src/db/model/state.rs
+++ b/src/db/model/state.rs
@@ -73,14 +73,33 @@ pub mod candidate_kind {
pub const FIRST_INTRODUCTION: &str = "first_introduction";
}
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
-#[serde(rename_all = "snake_case")]
-pub enum ReleaseState {
- Published,
- Withdrawn,
- FailedUnbuilt,
+/// The real definition. The module is private, so this `pub`
+/// is not a nameable path from outside; the alias below is the
+/// only way to reach it, and the alias is what carries the
+/// feature-conditional visibility.
+mod release_state {
+ use super::*;
+
+ #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
+ #[serde(rename_all = "snake_case")]
+ pub enum ReleaseState {
+ Published,
+ Withdrawn,
+ FailedUnbuilt,
+ }
}
+/// The state column of a release row. `ReleaseRow` is public and its `state` field is typed here, so the type stays reachable in a release build only through this alias.
+///
+/// `pub` only under `test-support`. Production reaches the type
+/// through its own module and never names it from outside; the
+/// outside reader that needs the name is a test.
+#[cfg(feature = "test-support")]
+pub use release_state::ReleaseState;
+
+#[cfg(not(feature = "test-support"))]
+pub(crate) use release_state::ReleaseState;
+
impl ReleaseState {
const ALL: &'static [ReleaseState] = &[
ReleaseState::Published,