This commit is contained in:
parent
3486d44bc5
commit
5eb16ac38e
13
src/lib.rs
13
src/lib.rs
@ -18,9 +18,6 @@ mod statics;
|
||||
pub mod telemetry;
|
||||
mod template;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
use crate::{
|
||||
cache::CacheState,
|
||||
config::Settings,
|
||||
@ -63,10 +60,6 @@ struct GeneratorForm<'a> {
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct State {
|
||||
settings: Settings,
|
||||
// repos: String,
|
||||
// cache: String,
|
||||
// repos: settings.repodir.display().to_string(),
|
||||
// cache: settings.cachedir.display().to_string(),
|
||||
}
|
||||
|
||||
impl State {
|
||||
@ -482,11 +475,7 @@ async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Res
|
||||
let repo_count =
|
||||
// TODO: errorhandling
|
||||
web::Data::new(AtomicUsize::new(count::count_repositories(&settings.repodir).unwrap()));
|
||||
let state = web::Data::new(State {
|
||||
settings
|
||||
// repos: settings.repodir.display().to_string(),
|
||||
// cache: settings.cachedir.display().to_string(),
|
||||
});
|
||||
let state = web::Data::new(State { settings });
|
||||
Ok(HttpServer::new(move || {
|
||||
App::new()
|
||||
.app_data(state.clone())
|
||||
|
68
src/tests.rs
68
src/tests.rs
@ -1,68 +0,0 @@
|
||||
use crate::{
|
||||
calculate_hoc, index, json_hoc,
|
||||
service::{Bitbucket, GitHub, Gitlab, Service},
|
||||
State,
|
||||
};
|
||||
|
||||
use actix_web::{http, test, web, App};
|
||||
use tempfile::tempdir;
|
||||
|
||||
macro_rules! test_app {
|
||||
($path: expr) => {
|
||||
test::init_service(App::new().service($path)).await
|
||||
};
|
||||
($state: expr, $path: expr) => {
|
||||
test::init_service(App::new().data($state).service($path)).await
|
||||
};
|
||||
}
|
||||
|
||||
// macro_rules! test_service {
|
||||
// ($name: ident, $path: tt, $what: ident) => {
|
||||
// async fn $name<T: 'static + Service>(req_path: &str) {
|
||||
// let repo_dir = dbg!(tempdir().unwrap());
|
||||
// let cache_dir = dbg!(tempdir().unwrap());
|
||||
// let repos = format!("{}/", repo_dir.path().display());
|
||||
// let cache = format!("{}/", cache_dir.path().display());
|
||||
// let state = dbg!(State { repos, cache });
|
||||
|
||||
// let mut app = test_app!(state, web::resource($path).to($what::<T>));
|
||||
|
||||
// let req = dbg!(test::TestRequest::with_uri(req_path).to_request());
|
||||
// let resp = dbg!(test::call_service(&mut app, req).await);
|
||||
|
||||
// assert_eq!(resp.status(), http::StatusCode::OK);
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
|
||||
// #[actix_rt::test]
|
||||
// async fn test_index() {
|
||||
// std::env::set_var("HOC_BASE_URL", "http://0.0.0.0:8080");
|
||||
|
||||
// let mut app = test_app!(index);
|
||||
|
||||
// let req = dbg!(test::TestRequest::with_uri("/").to_request());
|
||||
// let resp = dbg!(test::call_service(&mut app, req).await);
|
||||
|
||||
// assert_eq!(resp.status(), http::StatusCode::OK);
|
||||
// }
|
||||
|
||||
// // TODO: fix this test
|
||||
// // #[actix_rt::test]
|
||||
// async fn test_json() {
|
||||
// test_service!(test_json_service, "/service/{user}/{repo}/json", json_hoc);
|
||||
|
||||
// test_json_service::<Gitlab>("/service/vbrandl/hoc/json").await;
|
||||
// test_json_service::<GitHub>("/service/vbrandl/hoc/json").await;
|
||||
// test_json_service::<Bitbucket>("/service/vbrandl/hoc/json").await;
|
||||
// }
|
||||
|
||||
// // TODO: fix this test
|
||||
// // #[actix_rt::test]
|
||||
// async fn test_badge() {
|
||||
// test_service!(test_badge_service, "/service/{user}/{repo}", calculate_hoc);
|
||||
|
||||
// test_badge_service::<Gitlab>("/service/vbrandl/hoc").await;
|
||||
// test_badge_service::<GitHub>("/service/vbrandl/hoc").await;
|
||||
// test_badge_service::<Bitbucket>("/service/vbrandl/hoc").await;
|
||||
// }
|
Loading…
Reference in New Issue
Block a user