Commit 1a1a43c1 authored by MrMan's avatar MrMan

Progress forming first test

parent 5b6588dc
Pipeline #47780695 failed with stage
in 2 minutes and 3 seconds
......@@ -1136,6 +1136,7 @@ dependencies = [
"fern 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mail 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rs-docker 0.0.51 (registry+https://github.com/rust-lang/crates.io-index)",
"rusqlite 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
......
......@@ -28,3 +28,4 @@ simple-signal = "1.1.1"
tempfile = "3"
mail = "0.6.7"
rs-docker = "0.0.51"
rand = "0.5.0"
\ No newline at end of file
......@@ -58,6 +58,9 @@ run:
test:
cargo test
test-e2e:
cargo test -- --ignored
watch: check-tool-cargo check-tool-cargo-watch
cargo watch -x build
......
extern crate tempfile;
extern crate rs_docker;
extern crate rand;
pub mod fixtures;
use rand::Rng;
use rand::distributions::Alphanumeric;
use rand::seq::sample_iter;
use self::rand::{thread_rng, Rng};
use self::rand::distributions::Alphanumeric;
use self::rand::seq::sample_iter;
use self::rs_docker::Docker;
use std::net::TcpListener;
use std::io::{Error as IOError};
// Get available port
// https://elliotekj.com/2017/07/25/find-available-tcp-port-rust/
......@@ -14,7 +16,7 @@ const TMP_PORT_RANGE_END: u16 = 9000;
const STARTUP_EXTRA_WAIT: u64 = 100;
fn get_available_port() -> Option<u16> {
let mut rng = rand::thread_rng();
let mut rng = thread_rng();
let mut available = false;
let mut port = 0;
......@@ -27,13 +29,26 @@ fn get_available_port() -> Option<u16> {
}
fn port_is_available(port: u16) -> bool {
match TcpListener::bind(("127.0.0.1", port)) {
Ok(_) => true,
Err(_) => false,
TcpListener::bind(("127.0.0.1", port)).is_ok()
}
pub struct DockerizedPostmgr {
id: String,
}
impl DockerizedPostmgr {
pub fn new() -> DockerizedPostmgr {
let id = thread_rng()
.sample_iter(&Alphanumeric)
.take(10)
.collect::<String>();
DockerizedPostmgr{ id }
}
}
fn start_dockerized_postmgr() -> Result<DockerizedPostmgrInfo> {
return Err(std::io::Error("Nope"));
impl Drop for DockerizedPostmgr {
fn drop(&mut self) {
println!("dropping postmgr w/ id [{}]", self.id)
}
}
mod common;
use crate::common::DockerizedPostmgr;
#[test]
#[ignore]
/// Test basic SMTP connectivity
pub fn test_smtp_connect() {
let postmgr = DockerizedPostmgr::new();
// TODO: start postmgr in a docker container
}
// TODO: test create user & login
// TODO: test sending email
// TODO: test sending email between local users (?)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment