Use DBPath for backup_restore test and remove _rust_rocksdb* from .gitignore (#419)

master
wqfish 5 years ago committed by GitHub
parent 5ce7c93306
commit 3d1a15bc38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .gitignore
  2. 8
      tests/test_backup.rs

1
.gitignore vendored

@ -3,7 +3,6 @@ target
Cargo.lock Cargo.lock
*.orig *.orig
*.bk *.bk
_rust_rocksdb*
*rlib *rlib
tags tags
path path

@ -16,7 +16,7 @@ mod util;
use rocksdb::{ use rocksdb::{
backup::{BackupEngine, BackupEngineOptions, RestoreOptions}, backup::{BackupEngine, BackupEngineOptions, RestoreOptions},
Options, DB, DB,
}; };
use util::DBPath; use util::DBPath;
@ -25,15 +25,13 @@ fn backup_restore() {
// create backup // create backup
let path = DBPath::new("backup_test"); let path = DBPath::new("backup_test");
let restore_path = DBPath::new("restore_from_backup_path"); let restore_path = DBPath::new("restore_from_backup_path");
let mut opts = Options::default();
opts.create_if_missing(true);
{ {
let db = DB::open(&opts, &path).unwrap(); let db = DB::open_default(&path).unwrap();
assert!(db.put(b"k1", b"v1111").is_ok()); assert!(db.put(b"k1", b"v1111").is_ok());
let value = db.get(b"k1"); let value = db.get(b"k1");
assert_eq!(value.unwrap().unwrap(), b"v1111"); assert_eq!(value.unwrap().unwrap(), b"v1111");
{ {
let backup_path = "_rust_rocksdb_backup_path"; let backup_path = DBPath::new("backup_path");
let backup_opts = BackupEngineOptions::default(); let backup_opts = BackupEngineOptions::default();
let mut backup_engine = BackupEngine::open(&backup_opts, &backup_path).unwrap(); let mut backup_engine = BackupEngine::open(&backup_opts, &backup_path).unwrap();
assert!(backup_engine.create_new_backup(&db).is_ok()); assert!(backup_engine.create_new_backup(&db).is_ok());

Loading…
Cancel
Save