Skip to content

Commit 6bd3945

Browse files
committed
Centralize PostgreSQL test URL env var
AI-Assisted-By: OpenAI Codex
1 parent 1508155 commit 6bd3945

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/io/postgres_store/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ pub const DEFAULT_DB_NAME: &str = "ldk_db";
3434
/// The default table in which we store all data.
3535
pub const DEFAULT_KV_TABLE_NAME: &str = "ldk_data";
3636

37+
/// Environment variable used by PostgreSQL tests and benchmarks.
38+
pub const POSTGRES_TEST_URL_ENV_VAR: &str = "TEST_POSTGRES_URL";
39+
3740
// The current schema version for the PostgreSQL store.
3841
const SCHEMA_VERSION: u16 = 1;
3942

@@ -807,7 +810,8 @@ mod tests {
807810
use crate::io::test_utils::{do_read_write_remove_list_persist, do_test_store};
808811

809812
fn test_connection_string() -> String {
810-
std::env::var("TEST_POSTGRES_URL")
813+
dotenvy::dotenv().ok();
814+
std::env::var(POSTGRES_TEST_URL_ENV_VAR)
811815
.unwrap_or_else(|_| "postgres://postgres:postgres@localhost/ldk_node_tests".to_string())
812816
}
813817

tests/integration_tests_postgres.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
mod common;
1111

1212
use ldk_node::entropy::NodeEntropy;
13+
use ldk_node::io::postgres_store::POSTGRES_TEST_URL_ENV_VAR;
1314
use ldk_node::Builder;
1415
use rand::RngCore;
1516

1617
fn test_connection_string() -> String {
17-
std::env::var("TEST_POSTGRES_URL")
18+
dotenvy::dotenv().ok();
19+
std::env::var(POSTGRES_TEST_URL_ENV_VAR)
1820
.unwrap_or_else(|_| "host=localhost user=postgres password=postgres".to_string())
1921
}
2022

0 commit comments

Comments
 (0)