@@ -12,6 +12,7 @@ pub struct Test<'a> {
12 second_migration: Option<Migration>,
12 second_migration: Option<Migration>,
13 expect_failure: bool,
13 expect_failure: bool,
15+ clear_fn: Option<fn(&mut Client) -> ()>,
15 after_first_fn: Option<fn(&mut Client) -> ()>,
16 after_first_fn: Option<fn(&mut Client) -> ()>,
16 intermediate_fn: Option<fn(&mut Client, &mut Client) -> ()>,
17 intermediate_fn: Option<fn(&mut Client, &mut Client) -> ()>,
17 after_completion_fn: Option<fn(&mut Client) -> ()>,
18 after_completion_fn: Option<fn(&mut Client) -> ()>,
@@ -36,6 +37,7 @@ impl Test<'_> {
36 first_migration: None,
37 first_migration: None,
37 second_migration: None,
38 second_migration: None,
38 expect_failure: false,
39 expect_failure: false,
39 after_first_fn: None,
41 after_first_fn: None,
40 intermediate_fn: None,
42 intermediate_fn: None,
41 after_completion_fn: None,
43 after_completion_fn: None,
@@ -54,6 +56,12 @@ impl Test<'_> {
60+ pub fn clear(&mut self, f: fn(&mut Client) -> ()) -> &mut Self {
61+ self.clear_fn = Some(f);
57 #[allow(dead_code)]
65 #[allow(dead_code)]
58 pub fn after_first(&mut self, f: fn(&mut Client) -> ()) -> &mut Self {
66 pub fn after_first(&mut self, f: fn(&mut Client) -> ()) -> &mut Self {
59 self.after_first_fn = Some(f);
67 self.after_first_fn = Some(f);
@@ -115,6 +123,10 @@ impl Test<'_> {
115 print_subheading("Clearing database");
123 print_subheading("Clearing database");
116 self.reshape.remove().unwrap();
124 self.reshape.remove().unwrap();
126+ if let Some(clear_fn) = self.clear_fn {
127+ clear_fn(&mut self.old_db);
118 // Apply first migration, will automatically complete
130 // Apply first migration, will automatically complete
119 print_subheading("Applying first migration");
131 print_subheading("Applying first migration");
120 let first_migration = self
132 let first_migration = self