From 73d0589dfc7ec6d6d47117469cd20c1e11732a22 Mon Sep 17 00:00:00 2001 From: yngrtc Date: Sun, 11 Feb 2024 12:54:58 -0800 Subject: [PATCH] setup integration tests --- tests/common/mod.rs | 26 ++++++++++++++++++++++++++ tests/datachannel_test.rs | 10 ++++++++++ tests/rtcp_test.rs | 10 ++++++++++ tests/rtp_test.rs | 10 ++++++++++ tests/signaling_test.rs | 10 ++++++++++ 5 files changed, 66 insertions(+) create mode 100644 tests/common/mod.rs create mode 100644 tests/datachannel_test.rs create mode 100644 tests/rtcp_test.rs create mode 100644 tests/rtp_test.rs create mode 100644 tests/signaling_test.rs diff --git a/tests/common/mod.rs b/tests/common/mod.rs new file mode 100644 index 0000000..0c52413 --- /dev/null +++ b/tests/common/mod.rs @@ -0,0 +1,26 @@ +use log::info; +use log::LevelFilter::Debug; +use std::io::Write; + +pub fn setup() -> anyhow::Result<()> { + env_logger::Builder::new() + .format(|buf, record| { + writeln!( + buf, + "{}:{} [{}] {} - {}", + record.file().unwrap_or("unknown"), + record.line().unwrap_or(0), + record.level(), + chrono::Local::now().format("%H:%M:%S.%6f"), + record.args() + ) + }) + .filter(None, Debug) + .try_init()?; + + // some setup code, like creating required files/directories, starting + // servers, etc. + info!("common setup"); + + Ok(()) +} diff --git a/tests/datachannel_test.rs b/tests/datachannel_test.rs new file mode 100644 index 0000000..48f1019 --- /dev/null +++ b/tests/datachannel_test.rs @@ -0,0 +1,10 @@ +// importing common module. +mod common; + +#[test] +fn test_datachannel() -> anyhow::Result<()> { + // using common code. + common::setup()?; + + Ok(()) +} diff --git a/tests/rtcp_test.rs b/tests/rtcp_test.rs new file mode 100644 index 0000000..315e768 --- /dev/null +++ b/tests/rtcp_test.rs @@ -0,0 +1,10 @@ +// importing common module. +mod common; + +#[test] +fn test_rtcp() -> anyhow::Result<()> { + // using common code. + common::setup()?; + + Ok(()) +} diff --git a/tests/rtp_test.rs b/tests/rtp_test.rs new file mode 100644 index 0000000..2affb51 --- /dev/null +++ b/tests/rtp_test.rs @@ -0,0 +1,10 @@ +// importing common module. +mod common; + +#[test] +fn test_rtp() -> anyhow::Result<()> { + // using common code. + common::setup()?; + + Ok(()) +} diff --git a/tests/signaling_test.rs b/tests/signaling_test.rs new file mode 100644 index 0000000..5c65c44 --- /dev/null +++ b/tests/signaling_test.rs @@ -0,0 +1,10 @@ +// importing common module. +mod common; + +#[test] +fn test_signaling() -> anyhow::Result<()> { + // using common code. + common::setup()?; + + Ok(()) +}