mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
Fixes #8
```
$ cargo test
<--- snip --->
thread panicked while panicking. aborting.
Running unittests (target/debug/deps/tests_migrate-7d90f83f506b1b25)
```
gdb revealed that demo::demo_account_works receives a SIGKILL due to a
failed test. No idea why it didn't fail the usual way. The part where
the test fails hits an endpoint with the wrong datatype payload, it
should have failed with a 404 when the status was asserted but it
didn't. Fixing that fixed #8.
Additionally, all demo user functionality was restructured to include an
abort functionality, which can be used to kill the loop that deletes and
creates demo user throughout the runtime of the app.
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -54,6 +54,7 @@ pub use settings::Settings;
|
||||
use static_assets::FileMap;
|
||||
pub use widget::WIDGET_ROUTES;
|
||||
|
||||
use crate::demo::DemoUser;
|
||||
pub use crate::middleware::auth::CheckLogin;
|
||||
|
||||
lazy_static! {
|
||||
@@ -114,10 +115,14 @@ async fn main() -> std::io::Result<()> {
|
||||
sqlx::migrate!("./migrations/").run(&data.db).await.unwrap();
|
||||
let data = actix_web::web::Data::new(data);
|
||||
|
||||
let mut demo_user: Option<DemoUser> = None;
|
||||
|
||||
if SETTINGS.allow_demo && SETTINGS.allow_registration {
|
||||
demo::run(data.clone(), Duration::from_secs(60 * 30))
|
||||
.await
|
||||
.unwrap();
|
||||
demo_user = Some(
|
||||
DemoUser::spawn(data.clone(), Duration::from_secs(60 * 30))
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
println!("Starting server on: http://{}", SETTINGS.server.get_ip());
|
||||
@@ -141,7 +146,12 @@ async fn main() -> std::io::Result<()> {
|
||||
.bind(SETTINGS.server.get_ip())
|
||||
.unwrap()
|
||||
.run()
|
||||
.await
|
||||
.await?;
|
||||
|
||||
if let Some(demo_user) = demo_user {
|
||||
demo_user.abort();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
|
||||
Reference in New Issue
Block a user