Add a test covering DB::open_cf_descriptors()

master
Gary Tierney 7 years ago
parent c89a296dc1
commit b404f46012
  1. 42
      tests/test_column_family.rs

@ -14,7 +14,7 @@
//
extern crate rocksdb;
use rocksdb::{DB, MergeOperands, Options};
use rocksdb::{DB, MergeOperands, Options, ColumnFamilyDescriptor};
#[test]
pub fn test_column_family() {
@ -166,3 +166,43 @@ fn test_provided_merge(_: &[u8],
}
result
}
#[test]
pub fn test_column_family_with_options() {
let path = "_rust_rocksdb_cf_with_optionstest";
{
let mut cfopts = Options::default();
cfopts.set_max_write_buffer_number(16);
let cf_descriptor = ColumnFamilyDescriptor::new("cf1", cfopts);
let mut opts = Options::default();
opts.create_if_missing(true);
opts.create_missing_column_families(true);
let cfs = vec![cf_descriptor];
match DB::open_cf_descriptors(&opts, path, cfs) {
Ok(_) => println!("created db with column family descriptors succesfully"),
Err(e) => {
panic!("could not create new database with column family descriptors: {}", e);
}
}
}
{
let mut cfopts = Options::default();
cfopts.set_max_write_buffer_number(16);
let cf_descriptor = ColumnFamilyDescriptor::new("cf1", cfopts);
let opts = Options::default();
let cfs = vec![cf_descriptor];
match DB::open_cf_descriptors(&opts, path, cfs) {
Ok(_) => println!("succesfully re-opened database with column family descriptorrs"),
Err(e) => {
panic!("unable to re-open database with column family descriptors: {}", e);
}
}
}
assert!(DB::destroy(&Options::default(), path).is_ok());
}
Loading…
Cancel
Save