From 1e83ad7bbd8834d555bb0e7387e824a2ea1fe503 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 21 Sep 2016 10:08:01 +0200 Subject: [PATCH] Add test for hook execution for each hook position --- libimagstore/src/store.rs | 57 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 4a9a4524..cbe7b54d 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -2654,9 +2654,64 @@ aspect = "test" } #[test] - fn test_pre_create() { + fn test_storeunload() { + test_hook_execution(&[HP::StoreUnload]); + } + + #[test] + fn test_precreate() { test_hook_execution(&[HP::PreCreate]); } + #[test] + fn test_postcreate() { + test_hook_execution(&[HP::PostCreate]); + } + + #[test] + fn test_preretrieve() { + test_hook_execution(&[HP::PreRetrieve]); + } + + #[test] + fn test_postretrieve() { + test_hook_execution(&[HP::PostRetrieve]); + } + + #[test] + fn test_preupdate() { + test_hook_execution(&[HP::PreUpdate]); + } + + #[test] + fn test_postupdate() { + test_hook_execution(&[HP::PostUpdate]); + } + + #[test] + fn test_predelete() { + test_hook_execution(&[HP::PreDelete]); + } + + #[test] + fn test_postdelete() { + test_hook_execution(&[HP::PostDelete]); + } + + #[test] + fn test_multiple_same_position() { + let positions = [ HP::StoreUnload, HP::PreCreate, HP::PostCreate, HP::PreRetrieve, + HP::PostRetrieve, HP::PreUpdate, HP::PostUpdate, HP::PreDelete, HP::PostDelete ]; + + for position in positions.iter() { + for n in 2..10 { + let mut v = Vec::with_capacity(n); + for x in 0..n { v.push(position.clone()); } + + test_hook_execution(&v); + } + } + } + }