Skip to content

Commit 343c69a

Browse files
committed
only compile ApplyMode::Temporary in test mode
1 parent 5444d63 commit 343c69a

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/db/migrate.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::borrow::Cow;
1010
#[derive(Copy, Clone)]
1111
enum ApplyMode {
1212
Permanent,
13+
#[cfg(test)]
1314
Temporary,
1415
}
1516

@@ -22,6 +23,7 @@ impl MigrationContext {
2223
fn format_query<'a>(&self, query: &'a str) -> Cow<'a, str> {
2324
match self.apply_mode {
2425
ApplyMode::Permanent => Cow::Borrowed(query),
26+
#[cfg(test)]
2527
ApplyMode::Temporary => {
2628
Cow::Owned(query.replace("CREATE TABLE", "CREATE TEMPORARY TABLE"))
2729
}
@@ -73,6 +75,7 @@ pub fn migrate(version: Option<Version>, conn: &Connection) -> CratesfyiResult<(
7375
migrate_inner(version, conn, ApplyMode::Permanent)
7476
}
7577

78+
#[cfg(test)]
7679
pub fn migrate_temporary(version: Option<Version>, conn: &Connection) -> CratesfyiResult<()> {
7780
migrate_inner(version, conn, ApplyMode::Temporary)
7881
}

src/db/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ pub(crate) use self::add_package::add_build_into_database;
55
pub(crate) use self::add_package::CratesIoData;
66
pub use self::file::{add_path_into_database, move_to_s3};
77
pub use self::migrate::migrate;
8+
#[cfg(test)]
9+
pub(crate) use self::migrate::migrate_temporary;
810
pub use self::delete_crate::delete_crate;
911

1012
use postgres::{Connection, TlsMode};

0 commit comments

Comments
 (0)