+struct SchemaSanitizer {}
+
+impl SchemaSanitizer {
+ fn new() -> Self {
+ IS_TEST_SCHEMA_CLEAN.with(|cleanliness_reference| {
+ let mut is_clean_option = cleanliness_reference.borrow_mut();
+ *is_clean_option = Some(false);
+ });
+
+ DB_TEST_SCHEMA.with(|suffix_reference| {
+ let mut suffix_option = suffix_reference.borrow_mut();
+ let current_time = SystemTime::now();
+ let unix_time = current_time.duration_since(UNIX_EPOCH).expect("Time went backwards");
+ let timestamp_seconds = unix_time.as_secs();
+ let timestamp_nanos = unix_time.as_nanos();
+ let preimage = format!("{}", timestamp_nanos);
+ let suffix = Sha256dHash::hash(preimage.as_bytes()).into_inner().to_hex();
+ // the schema must start with a letter
+ let schema = format!("test_{}_{}", timestamp_seconds, suffix);
+ *suffix_option = Some(schema);
+ });
+
+ return Self {};
+ }
+}
+
+impl Drop for SchemaSanitizer {
+ fn drop(&mut self) {
+ IS_TEST_SCHEMA_CLEAN.with(|cleanliness_reference| {
+ let is_clean_option = cleanliness_reference.borrow();
+ if let Some(is_clean) = *is_clean_option {
+ assert_eq!(is_clean, true);
+ }
+ });
+ }
+}
+
+