changeset 300:8ed86e8a9a5e

db_impl: Test reuse_logs option.
author Lewin Bormann <lbo@spheniscida.de>
date Wed, 27 Sep 2017 05:25:52 +0000
parents b9dab37389f3
children eea316cf8f50
files src/db_impl.rs
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/db_impl.rs	Wed Sep 27 05:13:41 2017 +0000
+++ b/src/db_impl.rs	Wed Sep 27 05:25:52 2017 +0000
@@ -877,7 +877,7 @@
                      env.children(Path::new("db/")).unwrap());
             let mut opt = opt.clone();
             opt.reuse_manifest = false;
-            let db = DB::open("db", opt.clone()).unwrap();
+            let mut db = DB::open("db", opt.clone()).unwrap();
 
             println!("children after: {:?}",
                      env.children(Path::new("db/")).unwrap());
@@ -900,6 +900,7 @@
                            .unwrap()
                            .0
                            .as_slice());
+            db.put("abe".as_bytes(), "def".as_bytes()).unwrap();
         }
 
         {
@@ -919,6 +920,13 @@
             assert!(env.exists(Path::new("db/000004.log")).unwrap());
             // 000004 should be reused, no new log file should be created.
             assert!(!env.exists(Path::new("db/000006.log")).unwrap());
+            // Log is reused, so memtable should contain last written entry from above.
+            assert_eq!(1, db.mem.len());
+            assert_eq!("def".as_bytes(),
+                       db.mem
+                           .get(&LookupKey::new("abe".as_bytes(), 3))
+                           .unwrap()
+                           .as_slice());
         }
     }