From b404f46012c532e27ac7694d68e79bda2e2a435e Mon Sep 17 00:00:00 2001 From: Gary Tierney Date: Sun, 3 Sep 2017 18:33:24 +0100 Subject: [PATCH] Add a test covering DB::open_cf_descriptors() --- tests/test_column_family.rs | 42 ++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/tests/test_column_family.rs b/tests/test_column_family.rs index 82eccc3..0100445 100644 --- a/tests/test_column_family.rs +++ b/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()); +} \ No newline at end of file