diff --git a/src/cache/cache_container.rs b/src/cache/cache_container.rs index cb0423b..8a36b99 100644 --- a/src/cache/cache_container.rs +++ b/src/cache/cache_container.rs @@ -382,10 +382,7 @@ mod tests { let tempdir = tempfile::tempdir().unwrap(); let db = create_test_db(tempdir.path()); let to_parent = Arc::new(RwLock::new(HashMap::new())); - let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new( - db, - to_parent.clone().into(), - ))); + let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into()))); let snapshot_id = 1; let db_snapshot = CacheDb::new(snapshot_id, snapshot_manager.clone().into()); @@ -405,10 +402,7 @@ mod tests { let tempdir = tempfile::tempdir().unwrap(); let db = create_test_db(tempdir.path()); let to_parent = Arc::new(RwLock::new(HashMap::new())); - let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new( - db, - to_parent.clone().into(), - ))); + let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into()))); let snapshot_id = 1; // Both share the same ID @@ -429,7 +423,7 @@ mod tests { let tempdir = tempfile::tempdir().unwrap(); let db = create_test_db(tempdir.path()); let to_parent = Arc::new(RwLock::new(HashMap::new())); - let mut cache_container = CacheContainer::new(db, to_parent.clone().into()); + let mut cache_container = CacheContainer::new(db, to_parent.into()); cache_container.commit_snapshot(&1).unwrap(); } @@ -441,7 +435,7 @@ mod tests { let tempdir = tempfile::tempdir().unwrap(); let db = create_test_db(tempdir.path()); let to_parent = Arc::new(RwLock::new(HashMap::new())); - let mut cache_container = CacheContainer::new(db, to_parent.clone().into()); + let mut cache_container = CacheContainer::new(db, to_parent.into()); cache_container.discard_snapshot(&1); } @@ -451,10 +445,7 @@ mod tests { let tempdir = tempfile::tempdir().unwrap(); let db = create_test_db(tempdir.path()); let to_parent = Arc::new(RwLock::new(HashMap::new())); - let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new( - db, - to_parent.clone().into(), - ))); + let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into()))); let snapshot_id = 1; let db_snapshot = CacheDb::new(snapshot_id, snapshot_manager.clone().into()); @@ -473,7 +464,7 @@ mod tests { let tempdir = tempfile::tempdir().unwrap(); let db = create_test_db(tempdir.path()); let to_parent = Arc::new(RwLock::new(HashMap::new())); - let snapshot_manager = CacheContainer::new(db, to_parent.clone().into()); + let snapshot_manager = CacheContainer::new(db, to_parent.into()); assert_eq!(None, snapshot_manager.get::(1, &TestField(1)).unwrap()); } @@ -492,10 +483,7 @@ mod tests { db_data.put::(&three, &three).unwrap(); db.write_schemas(db_data).unwrap(); - let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new( - db, - to_parent.clone().into(), - ))); + let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into()))); let db_snapshot = CacheDb::new(1, snapshot_manager.clone().into()); db_snapshot.put::(&two, &two).unwrap(); @@ -543,10 +531,7 @@ mod tests { db_data.put::(&f1, &f1).unwrap(); db.write_schemas(db_data).unwrap(); - let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new( - db, - to_parent.clone().into(), - ))); + let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into()))); // Operations: // | snapshot_id | key | operation | @@ -698,10 +683,7 @@ mod tests { // | 0 | 1 | // | 11 | 9 | - let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new( - db, - to_parent.clone().into(), - ))); + let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into()))); // Operations: // | snapshot_id | key | operation | @@ -908,10 +890,7 @@ mod tests { } } - let cache_container = Arc::new(RwLock::new(CacheContainer::new( - db, - to_parent.clone().into(), - ))); + let cache_container = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into()))); // Creating snapshots let n_chunks = 10; // Number of chunks you want diff --git a/tests/iterator_test.rs b/tests/iterator_test.rs index 96af04f..e49d885 100644 --- a/tests/iterator_test.rs +++ b/tests/iterator_test.rs @@ -363,10 +363,7 @@ fn test_db_snapshot_get_last_value() { let mut to_parent = to_parent.write().unwrap(); to_parent.insert(1, 0); } - let manager = Arc::new(RwLock::new(CacheContainer::new( - db.db, - to_parent.clone().into(), - ))); + let manager = Arc::new(RwLock::new(CacheContainer::new(db.db, to_parent.into()))); let snapshot_1 = CacheDb::new(0, ReadOnlyLock::new(manager.clone())); @@ -396,7 +393,7 @@ fn test_db_snapshot_get_last_value() { manager.add_snapshot(snapshot_1.into()).unwrap(); } - let snapshot_2 = CacheDb::new(1, ReadOnlyLock::new(manager.clone())); + let snapshot_2 = CacheDb::new(1, ReadOnlyLock::new(manager)); { let (latest_key, latest_value) = snapshot_2 @@ -454,10 +451,7 @@ fn test_db_cache_container_get_prev_value() { to_parent.insert(1, 0); to_parent.insert(2, 1); } - let cache_container = Arc::new(RwLock::new(CacheContainer::new( - db, - to_parent.clone().into(), - ))); + let cache_container = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into()))); // Snapshots 1 and 2 are to black box usages of parents iterator let snapshot_1 = CacheDb::new(0, ReadOnlyLock::new(cache_container.clone())); @@ -537,7 +531,7 @@ fn test_db_cache_container_get_prev_value() { let mut manager = cache_container.write().unwrap(); manager.add_snapshot(snapshot_2.into()).unwrap(); } - let snapshot_3 = CacheDb::new(2, ReadOnlyLock::new(cache_container.clone())); + let snapshot_3 = CacheDb::new(2, ReadOnlyLock::new(cache_container)); assert_eq!( (key_2.clone(), TestField(20)), snapshot_3 @@ -546,7 +540,7 @@ fn test_db_cache_container_get_prev_value() { .unwrap() ); assert_eq!( - (key_2.clone(), TestField(20)), + (key_2, TestField(20)), snapshot_3.get_prev::(&key_1).unwrap().unwrap() ); assert_eq!( diff --git a/tests/snapshot_test.rs b/tests/snapshot_test.rs index 36737ba..6594d6e 100644 --- a/tests/snapshot_test.rs +++ b/tests/snapshot_test.rs @@ -74,7 +74,7 @@ fn snapshot_lifecycle() { } // Snapshot 3: gets empty result, event value is in some previous snapshots - let snapshot_3 = CacheDb::new(2, ReadOnlyLock::new(manager.clone())); + let snapshot_3 = CacheDb::new(2, ReadOnlyLock::new(manager)); { let mut to_parent = to_parent.write().unwrap(); to_parent.insert(2, 1);