New snapshot tests

This commit is contained in:
Lucien Greathouse 2019-03-12 15:58:22 -07:00
parent ad93631ef8
commit 684a33c418
12 changed files with 921 additions and 90 deletions

View file

@ -2,30 +2,10 @@ use std::fs::{create_dir, copy};
use std::path::Path;
use std::io;
use rouille::Request;
use walkdir::WalkDir;
use librojo::web::Server;
pub trait HttpTestUtil {
fn get_string(&self, url: &str) -> String;
}
impl HttpTestUtil for Server {
fn get_string(&self, url: &str) -> String {
let info_request = Request::fake_http("GET", url, vec![], vec![]);
let response = self.handle_request(&info_request);
assert_eq!(response.status_code, 200);
let (mut reader, _) = response.data.into_reader_and_size();
let mut body = String::new();
reader.read_to_string(&mut body).unwrap();
body
}
}
pub mod snapshot;
pub mod tree;
pub fn copy_recursive(from: &Path, to: &Path) -> io::Result<()> {
for entry in WalkDir::new(from) {
@ -51,4 +31,4 @@ pub fn copy_recursive(from: &Path, to: &Path) -> io::Result<()> {
}
Ok(())
}
}