mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-10-05 03:56:45 +08:00
- Changed `run_id` to `request_id` in `CursorParent` struct for clarity. - Enhanced the `prepare` function to handle parent requests asynchronously, ensuring proper error handling for active runs. - Updated database interactions to include `cursor_request_id` for better tracking of requests. - Added tests to verify the behavior of reused cursor request IDs and their mapping to distinct executions.
44 lines
1.2 KiB
Rust
44 lines
1.2 KiB
Rust
use std::borrow::Cow;
|
|
|
|
use cursor_server::store::Store;
|
|
use sqlx::{migrate::Migrator, sqlite::SqliteConnectOptions, Row};
|
|
|
|
#[tokio::test]
|
|
async fn version_two_database_upgrades_with_cursor_request_mapping() {
|
|
let directory = tempfile::tempdir().unwrap();
|
|
let database = directory.path().join("upgrade.db");
|
|
let pool = sqlx::SqlitePool::connect_with(
|
|
SqliteConnectOptions::new()
|
|
.filename(&database)
|
|
.create_if_missing(true),
|
|
)
|
|
.await
|
|
.unwrap();
|
|
let all = sqlx::migrate!("./migrations");
|
|
let prior = Migrator {
|
|
migrations: Cow::Owned(
|
|
all.iter()
|
|
.filter(|migration| migration.version <= 2)
|
|
.cloned()
|
|
.collect(),
|
|
),
|
|
ignore_missing: false,
|
|
locking: true,
|
|
no_tx: false,
|
|
};
|
|
prior.run(&pool).await.unwrap();
|
|
drop(pool);
|
|
|
|
let store = Store::connect(&format!("sqlite://{}", database.display()))
|
|
.await
|
|
.unwrap();
|
|
let columns = sqlx::query("PRAGMA table_info(runs)")
|
|
.fetch_all(store.pool())
|
|
.await
|
|
.unwrap();
|
|
|
|
assert!(columns
|
|
.iter()
|
|
.any(|column| column.get::<String, _>("name") == "cursor_request_id"));
|
|
}
|