mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:19:04 +00:00
Require absolute paths for test SQLite configuration (#34411)
## Why `SqliteConfig` stores its home as an `AbsolutePathBuf`, but its test constructor previously accepted a `PathBuf` and checked the absolute-path invariant at runtime. ## What changed - Make `SqliteConfig::new_for_testing` accept an `AbsolutePathBuf` directly, removing its fallible conversion and `expect`. - Update SQLite test setup to convert temporary directory paths with `PathExt::abs` at each call site. GitOrigin-RevId: 93585b9aea805e2449b3465ac20eeb39417ed555
This commit is contained in:
1 parent
44481a1c45
commit
81e89fa5af
8 files changed
+26
-27
No files matched your search
@@ -112,6 +112,7 @@ mod tests {
|
||||
use super::StateRuntime;
|
||||
use super::test_support::unique_temp_dir;
|
||||
use chrono::Utc;
|
||||
use codex_utils_absolute_path::test_support::PathExt;
|
||||
use pretty_assertions::assert_eq;
|
||||
use sqlx::Connection;
|
||||
|
||||
@@ -174,7 +175,7 @@ mod tests {
|
||||
let runtime = StateRuntime::init(codex_home.clone(), "test-provider".to_string())
|
||||
.await
|
||||
.expect("initialize runtime");
|
||||
let write_pool = crate::SqliteConfig::new_for_testing(codex_home.clone())
|
||||
let write_pool = crate::SqliteConfig::new_for_testing(codex_home.as_path().abs())
|
||||
.open_read_write_pool(&crate::state_db_path(codex_home.as_path()))
|
||||
.await
|
||||
.expect("open write pool");
|
||||
|
||||
@@ -548,6 +548,7 @@ mod tests {
|
||||
use crate::logs_db_path;
|
||||
use crate::migrations::LOGS_MIGRATOR;
|
||||
use chrono::Utc;
|
||||
use codex_utils_absolute_path::test_support::PathExt;
|
||||
use pretty_assertions::assert_eq;
|
||||
use sqlx::SqlitePool;
|
||||
use sqlx::migrate::Migrator;
|
||||
@@ -555,7 +556,7 @@ mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
async fn open_db_pool(path: &Path) -> SqlitePool {
|
||||
crate::SqliteConfig::new_for_testing(path.parent().unwrap_or(path).to_path_buf())
|
||||
crate::SqliteConfig::new_for_testing(path.parent().unwrap_or(path).abs())
|
||||
.open_read_write_pool(path)
|
||||
.await
|
||||
.expect("open sqlite pool")
|
||||
@@ -617,7 +618,7 @@ mod tests {
|
||||
table_name: LOGS_MIGRATOR.table_name.clone(),
|
||||
create_schemas: LOGS_MIGRATOR.create_schemas.clone(),
|
||||
};
|
||||
let pool = crate::SqliteConfig::new_for_testing(codex_home.clone())
|
||||
let pool = crate::SqliteConfig::new_for_testing(codex_home.as_path().abs())
|
||||
.open_read_write_pool(&logs_path)
|
||||
.await
|
||||
.expect("open old logs db");
|
||||
|
||||
@@ -158,6 +158,7 @@ mod tests {
|
||||
use super::test_support::unique_temp_dir;
|
||||
use crate::migrations::STATE_MIGRATOR;
|
||||
use crate::state_db_path;
|
||||
use codex_utils_absolute_path::test_support::PathExt;
|
||||
use pretty_assertions::assert_eq;
|
||||
use sqlx::migrate::Migrator;
|
||||
use std::borrow::Cow;
|
||||
@@ -336,7 +337,7 @@ mod tests {
|
||||
table_name: STATE_MIGRATOR.table_name.clone(),
|
||||
create_schemas: STATE_MIGRATOR.create_schemas.clone(),
|
||||
};
|
||||
let pool = crate::SqliteConfig::new_for_testing(codex_home.clone())
|
||||
let pool = crate::SqliteConfig::new_for_testing(codex_home.as_path().abs())
|
||||
.open_read_write_pool(&state_db_path(codex_home.as_path()))
|
||||
.await
|
||||
.expect("open old state db");
|
||||
|
||||
Reference in new issue
Block a user