Last active
November 6, 2017 13:58
-
-
Save leoyvens/9ddcf109a83a9c912d1313eea550607f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[allow(unused_imports)] | |
#[macro_use] | |
extern crate lazy_static; | |
#[cfg(test)] | |
mod tests { | |
use std::sync::{Mutex, MutexGuard, Once, ONCE_INIT}; | |
/// Substitua String pelo tipo da sua conexão. | |
lazy_static! { | |
static ref CONN: Mutex<Option<String>> = Mutex::new(None); | |
} | |
static DO_SETUP: Once = ONCE_INIT; | |
fn get_conn() -> MutexGuard<'static, Option<String>> { | |
DO_SETUP.call_once(|| { | |
*CONN.lock().unwrap() = Some("Conectado".to_string()); | |
}); | |
CONN.lock().unwrap() | |
} | |
#[test] | |
fn testonildo() { | |
let mut conn_guard = get_conn(); | |
let conn = conn_guard.as_mut().unwrap(); | |
// Seja feliz testando sua conexão. | |
} | |
/// Não faço ideia de onde você chamaria isso. | |
fn teardown() { | |
*CONN.lock().unwrap() = None; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment