Skip to content

Commit ff3c7e5

Browse files
committed
chore: formatted and pub(crate) visibility
1 parent 1b947fd commit ff3c7e5

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

rust/impls/src/migrations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub(crate) const MIGRATION_LOG_COLUMN: &str = "upgrade_from";
55
pub(crate) const CHECK_DB_STMT: &str = "SELECT 1 FROM pg_database WHERE datname = $1";
66
pub(crate) const INIT_DB_CMD: &str = "CREATE DATABASE";
77
#[cfg(test)]
8-
const DROP_DB_CMD: &str = "DROP DATABASE";
8+
pub(crate) const DROP_DB_CMD: &str = "DROP DATABASE";
99
pub(crate) const GET_VERSION_STMT: &str = "SELECT db_version FROM vss_db_version;";
1010
pub(crate) const UPDATE_VERSION_STMT: &str = "UPDATE vss_db_version SET db_version=$1;";
1111
pub(crate) const LOG_MIGRATION_STMT: &str = "INSERT INTO vss_db_upgrades VALUES($1);";
@@ -36,4 +36,4 @@ pub(crate) const MIGRATIONS: &[&str] = &[
3636
);",
3737
];
3838
#[cfg(test)]
39-
const DUMMY_MIGRATION: &str = "SELECT 1 WHERE FALSE;";
39+
pub(crate) const DUMMY_MIGRATION: &str = "SELECT 1 WHERE FALSE;";

rust/impls/src/postgres_store.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ async fn drop_database(postgres_endpoint: &str, db_name: &str) -> Result<(), Err
9393

9494
let drop_database_statement = format!("{} {};", DROP_DB_CMD, db_name);
9595
let num_rows = client.execute(&drop_database_statement, &[]).await.map_err(|e| {
96-
Error::new(
97-
ErrorKind::Other,
98-
format!("Failed to drop database {}: {}", db_name, e),
99-
)
96+
Error::new(ErrorKind::Other, format!("Failed to drop database {}: {}", db_name, e))
10097
})?;
10198
assert_eq!(num_rows, 0);
10299

@@ -134,10 +131,7 @@ impl PostgresBackendImpl {
134131

135132
async fn migrate_vss_database(&self, migrations: &[&str]) -> Result<(usize, usize), Error> {
136133
let mut conn = self.pool.get().await.map_err(|e| {
137-
Error::new(
138-
ErrorKind::Other,
139-
format!("Failed to fetch a connection from Pool: {}", e),
140-
)
134+
Error::new(ErrorKind::Other, format!("Failed to fetch a connection from Pool: {}", e))
141135
})?;
142136

143137
// Get the next migration to be applied.
@@ -230,7 +224,9 @@ impl PostgresBackendImpl {
230224
async fn get_upgrades_list(&self) -> Vec<usize> {
231225
let conn = self.pool.get().await.unwrap();
232226
let rows = conn.query(GET_MIGRATION_LOG_STMT, &[]).await.unwrap();
233-
rows.iter().map(|row| usize::try_from(row.get::<&str, i32>(MIGRATION_LOG_COLUMN)).unwrap()).collect()
227+
rows.iter()
228+
.map(|row| usize::try_from(row.get::<&str, i32>(MIGRATION_LOG_COLUMN)).unwrap())
229+
.collect()
234230
}
235231

236232
fn build_vss_record(&self, user_token: String, store_id: String, kv: KeyValue) -> VssDbRecord {
@@ -581,10 +577,10 @@ impl KvStore for PostgresBackendImpl {
581577

582578
#[cfg(test)]
583579
mod tests {
580+
use super::{drop_database, DUMMY_MIGRATION, MIGRATIONS};
584581
use crate::postgres_store::PostgresBackendImpl;
585582
use api::define_kv_store_tests;
586583
use tokio::sync::OnceCell;
587-
use super::{MIGRATIONS, DUMMY_MIGRATION, drop_database};
588584

589585
const POSTGRES_ENDPOINT: &str = "postgresql://postgres:postgres@localhost:5432";
590586
const MIGRATIONS_START: usize = 0;
@@ -670,7 +666,10 @@ mod tests {
670666
let (start, end) = store.migrate_vss_database(&migrations).await.unwrap();
671667
assert_eq!(start, MIGRATIONS_END + 1);
672668
assert_eq!(end, MIGRATIONS_END + 3);
673-
assert_eq!(store.get_upgrades_list().await, [MIGRATIONS_START, MIGRATIONS_END, MIGRATIONS_END + 1]);
669+
assert_eq!(
670+
store.get_upgrades_list().await,
671+
[MIGRATIONS_START, MIGRATIONS_END, MIGRATIONS_END + 1]
672+
);
674673
assert_eq!(store.get_schema_version().await, MIGRATIONS_END + 3);
675674
};
676675

0 commit comments

Comments
 (0)