Skip to content

Commit

Permalink
engine_traits_tests: Another CFNamesExt test
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Anderson <andersrb@gmail.com>
  • Loading branch information
brson committed Oct 22, 2020
1 parent 638fef1 commit 42410d2
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions components/engine_traits_tests/src/lib.rs
Expand Up @@ -44,6 +44,18 @@ fn default_engine() -> TempDirEnginePair {
}
}

fn engine_cfs(cfs: &[&str]) -> TempDirEnginePair {
use engine_test::kv::KvTestEngine;
use engine_test::ctor::EngineConstructorExt;

let dir = tempdir();
let path = dir.path().to_str().unwrap();
let engine = KvTestEngine::new_engine(path, None, cfs, None).unwrap();
TempDirEnginePair {
engine, tempdir: dir,
}
}


mod ctor {
//! Constructor tests
Expand Down Expand Up @@ -96,3 +108,27 @@ mod basic_read_write {
assert_eq!(expected, &*actual);
}
}

mod cf_names {
use super::{default_engine, engine_cfs};
use engine_traits::CFNamesExt;
use engine_traits::{CF_DEFAULT, ALL_CFS};

#[test]
fn default_names() {
let db = default_engine();
let names = db.engine.cf_names();
assert_eq!(names.len(), 1);
assert_eq!(names[0], CF_DEFAULT);
}

#[test]
fn cf_names() {
let db = engine_cfs(ALL_CFS);
let names = db.engine.cf_names();
assert_eq!(names.len(), ALL_CFS.len());
for cf in ALL_CFS {
assert!(names.contains(cf));
}
}
}

0 comments on commit 42410d2

Please sign in to comment.