Skip to content

Commit 670630d

Browse files
committed
Centralize PostgreSQL test URL env var
AI-Assisted-By: OpenAI Codex
1 parent 8219d71 commit 670630d

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/io/postgres_store/mod.rs

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

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

@@ -897,7 +900,7 @@ mod tests {
897900
use crate::io::test_utils::{do_read_write_remove_list_persist, do_test_store};
898901

899902
fn test_connection_string() -> String {
900-
std::env::var("TEST_POSTGRES_URL")
903+
std::env::var(POSTGRES_TEST_URL_ENV_VAR)
901904
.unwrap_or_else(|_| "postgres://postgres:postgres@localhost/ldk_node_tests".to_string())
902905
}
903906

tests/common/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ use ldk_node::config::{
4242
HumanReadableNamesConfig,
4343
};
4444
use ldk_node::entropy::{generate_entropy_mnemonic, NodeEntropy};
45+
#[cfg(feature = "postgres")]
46+
use ldk_node::io::postgres_store::POSTGRES_TEST_URL_ENV_VAR;
4547
use ldk_node::io::sqlite_store::SqliteStore;
4648
use ldk_node::payment::{PaymentDirection, PaymentKind, PaymentStatus, TransactionType};
4749
use ldk_node::probing::ProbingConfig;
@@ -2052,7 +2054,7 @@ impl TestSyncStoreInner {
20522054
/// `TEST_POSTGRES_URL` environment variable.
20532055
#[cfg(feature = "postgres")]
20542056
pub(crate) fn test_connection_string() -> String {
2055-
std::env::var("TEST_POSTGRES_URL")
2057+
std::env::var(POSTGRES_TEST_URL_ENV_VAR)
20562058
.unwrap_or_else(|_| "host=localhost user=postgres password=postgres".to_string())
20572059
}
20582060

0 commit comments

Comments
 (0)