#![allow(dead_code, unused_imports)]
use tango::server::ServerBuilder;
use tango::testing::{TestDatabase, TestContext};
pub fn test_context(listed: &[(&str, &str)]) -> TestContext {
let ctx = TestContext::new().unwrap();
ctx.database().add_server("Test/test", listed).unwrap();
ctx.test_database().clear_log();
ctx
}
pub fn test_server(local: bool) -> ServerBuilder {
ServerBuilder::new("Test", "test").local(local)
}
macro_rules! local_and_wire {
($(#[$meta:meta])* fn $name:ident($local:ident: bool) $body:block) => {
mod $name {
use super::*;
fn run($local: bool) $body
#[test]
$(#[$meta])*
fn local() {
run(true)
}
#[test]
$(#[$meta])*
fn wire() {
run(false)
}
}
};
}
pub(crate) use local_and_wire;
pub fn is_local(ctx: &TestContext, name: &str) -> bool {
ctx.is_local(name).unwrap()
}
pub fn commands(database: &TestDatabase) -> Vec<String> {
database.log().into_iter().map(|(name, _)| name).collect()
}
pub fn exported(database: &TestDatabase) -> Vec<String> {
database.log().into_iter()
.filter(|(name, _)| name == "DbExportDevice" || name == "DbExportServer")
.flat_map(|(_, input)| Vec::<String>::try_from(input).unwrap().into_iter().step_by(5))
.collect()
}
pub fn unexported(database: &TestDatabase) -> Vec<String> {
database.log().into_iter()
.filter(|(name, _)| name == "DbUnExportDevice" || name == "DbUnExportServer")
.map(|(_, input)| String::try_from(input).unwrap())
.collect()
}