mirror of
https://github.com/GothenburgBitFactory/taskchampion-sync-server.git
synced 2025-06-26 10:54:29 +02:00
Improve error handling in the inmemory storage implementation. (#79)
Improve error handling in the inmemory storage This addresses a TODO, in a type that is really only used for testing. This also adds a test for a similar circumstance -- adding the same version twice -- in the SQLite storage, but it is already handled correctly.
This commit is contained in:
parent
f3445d558e
commit
5332d90c57
2 changed files with 59 additions and 6 deletions
|
@ -385,6 +385,23 @@ mod test {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_version_exists() -> anyhow::Result<()> {
|
||||
let tmp_dir = TempDir::new()?;
|
||||
let storage = SqliteStorage::new(tmp_dir.path())?;
|
||||
let client_id = Uuid::new_v4();
|
||||
let mut txn = storage.txn(client_id)?;
|
||||
|
||||
let version_id = Uuid::new_v4();
|
||||
let parent_version_id = Uuid::new_v4();
|
||||
let history_segment = b"abc".to_vec();
|
||||
txn.add_version(version_id, parent_version_id, history_segment.clone())?;
|
||||
assert!(txn
|
||||
.add_version(version_id, parent_version_id, history_segment.clone())
|
||||
.is_err());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_snapshots() -> anyhow::Result<()> {
|
||||
let tmp_dir = TempDir::new()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue