diff --git a/.env.example b/.env.example index 899fea6..015f7ae 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,8 @@ # Server listen address LISTEN_ADDR=0.0.0.0:3000 -# Path to the MaxMind DB file -DB_PATH=/data/Merged-IP.mmdb +# Path to the MaxMind DB file (use data/Merged-IP.mmdb for local development) +DB_PATH=data/Merged-IP.mmdb # URL to download the MMDB database from DB_UPDATE_URL=https://github.com/NetworkCats/Merged-IP-Data/releases/latest/download/Merged-IP.mmdb diff --git a/.gitignore b/.gitignore index 3ffeec1..c1444fa 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ ehthumbs_vista.db # Project *.mmdb +data/ .env haproxy/certs/ diff --git a/tests/integration.rs b/tests/integration.rs index 67c34fc..0ef066c 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -8,16 +8,17 @@ use rustyip::db; use rustyip::handlers::AppState; use rustyip::routes::build_router; -fn test_db_path() -> &'static str { - let path = "/tmp/Merged-IP.mmdb"; - if !Path::new(path).exists() { +fn test_db_path() -> String { + let manifest_dir = env!("CARGO_MANIFEST_DIR"); + let path = format!("{manifest_dir}/data/Merged-IP.mmdb"); + if !Path::new(&path).exists() { panic!("Test MMDB not found at {path}. Download it first."); } path } fn build_test_app() -> axum::Router { - let reader = db::load_db(Path::new(test_db_path())).expect("failed to load test DB"); + let reader = db::load_db(Path::new(&test_db_path())).expect("failed to load test DB"); let shared_db = db::new_shared(reader); let state = AppState { db: shared_db,