aboutsummaryrefslogtreecommitdiff
path: root/tests/rand_fail.rs
diff options
context:
space:
mode:
authorDeterminant <tederminant@gmail.com>2020-06-10 16:17:40 -0400
committerDeterminant <tederminant@gmail.com>2020-06-10 16:17:40 -0400
commit32a88299721393a5cbd3b369091de7cb77da349c (patch)
tree2f97916d5b2934a4bb2b99c68723f16fd3835ec8 /tests/rand_fail.rs
parent617c515ec1834501d4835076de3adcfb495d8ef9 (diff)
add failure generator in test
Diffstat (limited to 'tests/rand_fail.rs')
-rw-r--r--tests/rand_fail.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/rand_fail.rs b/tests/rand_fail.rs
index 7499694..b4e30ac 100644
--- a/tests/rand_fail.rs
+++ b/tests/rand_fail.rs
@@ -1,11 +1,11 @@
#[cfg(test)]
extern crate growthring;
-use growthring::wal::{WALLoader, WALWriter, WALRingId, WALBytes};
+use growthring::wal::{WALLoader, WALWriter, WALStore, WALRingId, WALBytes};
mod common;
-fn test(records: Vec<String>, wal: &mut WALWriter<common::WALStoreEmul>) -> Box<[WALRingId]> {
+fn test<S: WALStore>(records: Vec<String>, wal: &mut WALWriter<S>) -> Box<[WALRingId]> {
let records: Vec<WALBytes> = records.into_iter().map(|s| s.into_bytes().into_boxed_slice()).collect();
let ret = wal.grow(&records).unwrap();
for ring_id in ret.iter() {
@@ -16,10 +16,11 @@ fn test(records: Vec<String>, wal: &mut WALWriter<common::WALStoreEmul>) -> Box<
#[test]
fn test_rand_fail() {
+ let fgen = common::SingleFailGen::new(100);
let mut state = common::WALStoreEmulState::new();
- let mut wal = WALLoader::new(common::WALStoreEmul::new(&mut state), 9, 8, 1000).recover().unwrap();
+ let mut wal = WALLoader::new(common::WALStoreEmul::new(&mut state, fgen), 9, 8, 1000).recover().unwrap();
for _ in 0..3 {
test(["hi", "hello", "lol"].iter().map(|s| s.to_string()).collect::<Vec<String>>(), &mut wal);
}
- let mut wal = WALLoader::new(common::WALStoreEmul::new(&mut state), 9, 8, 1000).recover().unwrap();
+ WALLoader::new(common::WALStoreEmul::new(&mut state, common::ZeroFailGen), 9, 8, 1000).recover().unwrap();
}