Add Debug back to TestContext

I accidentally removed this in an earlier PR.
This commit is contained in:
Floris Bruynooghe
2021-01-21 20:40:16 +01:00
parent b67fbedcef
commit 934dc420a8

View File

@@ -3,6 +3,7 @@
//! This module is only compiled for test runs.
use std::collections::BTreeMap;
use std::fmt;
use std::ops::Deref;
use std::str::FromStr;
use std::time::{Duration, Instant};
@@ -45,7 +46,6 @@ static CONTEXT_NAMES: Lazy<std::sync::RwLock<BTreeMap<u32, String>>> =
///
/// The temporary directory can be used to store the SQLite database,
/// see e.g. [test_context] which does this.
// #[derive(Debug)]
pub(crate) struct TestContext {
pub ctx: Context,
pub dir: TempDir,
@@ -55,6 +55,17 @@ pub(crate) struct TestContext {
event_sinks: Arc<RwLock<Vec<Box<EventSink>>>>,
}
impl fmt::Debug for TestContext {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TestContext")
.field("ctx", &self.ctx)
.field("dir", &self.dir)
.field("recv_idx", &self.recv_idx)
.field("event_sinks", &String::from("Vec<EventSink>"))
.finish()
}
}
impl TestContext {
/// Creates a new [TestContext].
///