Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Cache the test Postgres binary under the OS cache dir

Manav Rathi337518d9f561
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index ad6cb8c59d..43aeba646c 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -2602,6 +2602,7 @@ dependencies = [
name = "ente-test-support"
version = "0.0.0"
dependencies = [
+ "dirs 5.0.1",
"postgresql_embedded",
"uuid",
]
diff --git a/rust/crates/test-support/Cargo.toml b/rust/crates/test-support/Cargo.toml
index 49bbe22619..e551c80a38 100644
--- a/rust/crates/test-support/Cargo.toml
+++ b/rust/crates/test-support/Cargo.toml
@@ -5,5 +5,6 @@ description = "Runs a local Museum backed by a temporary Postgres for integratio
publish = false
[dependencies]
-postgresql_embedded = { version = "0.20", default-features = false, features = ["blocking", "rustls", "theseus"] }
-uuid = { version = "1.11", features = ["v4"] }
+dirs = "5.0.1"
+postgresql_embedded = { version = "0.20.4", default-features = false, features = ["blocking", "rustls", "theseus"] }
+uuid = { version = "1.23.1", features = ["v4"] }
diff --git a/rust/crates/test-support/src/postgres.rs b/rust/crates/test-support/src/postgres.rs
index 917194f31c..34a053f075 100644
--- a/rust/crates/test-support/src/postgres.rs
+++ b/rust/crates/test-support/src/postgres.rs
@@ -1,3 +1,5 @@
+use std::path::PathBuf;
+
use postgresql_embedded::Settings;
use postgresql_embedded::blocking::PostgreSQL;
@@ -40,6 +42,7 @@ pub fn start() -> TestResult<Postgres> {
temporary: true,
host: LOCAL_HOST.to_string(),
port: free_port()?,
+ installation_dir: install_dir()?,
..Settings::default()
};
let mut inner = PostgreSQL::new(settings);
@@ -48,3 +51,12 @@ pub fn start() -> TestResult<Postgres> {
inner.create_database(DATABASE)?;
Ok(Postgres { inner })
}
+
+// postgresql_embedded defaults its binary to a `~/.theseus` dir in $HOME; keep
+// that name but under the conventional cache directory instead.
+fn install_dir() -> TestResult<PathBuf> {
+ Ok(dirs::cache_dir()
+ .ok_or("could not resolve a cache directory")?
+ .join(".theseus")
+ .join("postgresql"))
+}