mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Explicit check that rusqlite::Transaction isn't auto-commited on drop
This commit is contained in:
parent
23531d73c4
commit
a3c9a76f1d
1 changed files with 29 additions and 0 deletions
|
@ -350,6 +350,35 @@ mod test {
|
|||
use crate::storage::taskmap_with;
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[test]
|
||||
fn drop_transaction() -> anyhow::Result<()> {
|
||||
let tmp_dir = TempDir::new()?;
|
||||
let mut storage = SqliteStorage::new(&tmp_dir.path())?;
|
||||
let uuid1 = Uuid::new_v4();
|
||||
let uuid2 = Uuid::new_v4();
|
||||
|
||||
{
|
||||
let mut txn = storage.txn()?;
|
||||
assert!(txn.create_task(uuid1)?);
|
||||
txn.commit()?;
|
||||
}
|
||||
|
||||
{
|
||||
let mut txn = storage.txn()?;
|
||||
assert!(txn.create_task(uuid2)?);
|
||||
std::mem::drop(txn); // Unnecessary explicit drop of transaction
|
||||
}
|
||||
|
||||
{
|
||||
let mut txn = storage.txn()?;
|
||||
let uuids = txn.all_task_uuids()?;
|
||||
|
||||
assert_eq!(uuids, [uuid1]);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create() -> anyhow::Result<()> {
|
||||
let tmp_dir = TempDir::new()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue