diff options
Diffstat (limited to 'src/db/mod.rs')
| -rw-r--r-- | src/db/mod.rs | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/db/mod.rs b/src/db/mod.rs index 5ac55c9..e42bae4 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -26,6 +26,8 @@ mod world; pub use migrations::MIGRATIONS; pub(crate) use model::StateEnum; +/// Its only caller is the test-tier `world_members`, so it is gated with it. +#[cfg(feature = "test-support")] pub(crate) use model::json_or; pub use model::{ @@ -36,7 +38,9 @@ pub use model::{ notice_kind, }; pub use audit::{AuditEntry, audit, audit_in, audit_system, list_audit}; -pub use invariants::{approved_but_unbuilt, unapproved_index_entries}; +pub use invariants::approved_but_unbuilt; +#[cfg(feature = "test-support")] +pub use invariants::unapproved_index_entries; pub use metrics::{ artifact_bytes_served, build_state_counts, count_index_packages, count_pending_reviews, count_published_releases, count_subscriptions, count_unacknowledged_notices, last_gc_age_secs, @@ -63,8 +67,12 @@ pub use retention::{ mark_release_purged, pkgbase_release_pointers, published_release_ids, record_gc_run, release_artifact_paths, serving_release_ids, }; -pub use settings::{all_settings, set_setting, setting, setting_i64}; -pub use snapshots::{SnapshotRow, put_snapshot, snapshot_by_commit, snapshot_by_id}; +pub use settings::{all_settings, setting, setting_i64}; +#[cfg(feature = "test-support")] +pub use settings::set_setting; +pub use snapshots::{SnapshotRow, put_snapshot, snapshot_by_id}; +#[cfg(feature = "test-support")] +pub use snapshots::snapshot_by_commit; pub use stage_b::{stage_b_cache_get, stage_b_cache_put, stage_b_recent}; pub use staleness::{ NewArtifact, approval_note, candidate_snapshot_id, index_recipes, @@ -75,7 +83,9 @@ pub use subscriptions::{ due_subscriptions, get_subscription, list_subscriptions, note_check, set_subscription_state, subscribe, }; -pub use world::{put_world_snapshot, world_members}; +pub use world::put_world_snapshot; +#[cfg(feature = "test-support")] +pub use world::world_members; pub(crate) fn state_col<T: StateEnum>(col: usize, text: &str) -> rusqlite::Result<T> { T::parse(text).ok_or_else(|| { @@ -160,6 +170,9 @@ type BoxedCall = Box<dyn FnOnce(&mut Connection) + Send>; enum Msg { Call(BoxedCall), + /// Only `Writer::shutdown` constructs this, and only the test tier calls + /// that; the server runs until the process ends. + #[cfg(feature = "test-support")] Shutdown, } @@ -184,6 +197,7 @@ impl Writer { for msg in rx.iter() { match msg { Msg::Call(f) => f(&mut conn), + #[cfg(feature = "test-support")] Msg::Shutdown => break, } } @@ -241,6 +255,12 @@ impl Writer { .map_err(|_| Error::db("writer actor gone")) } + /// Stop the writer actor. + /// + /// Test-tier only: the server runs until the process ends and never + /// quiesces the writer deliberately. Tests use it to prove a worker + /// that dies mid-write leaves the database consistent. +#[cfg(feature = "test-support")] pub fn shutdown(&self) { let _ = self.tx.send(Msg::Shutdown); } |
