diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-19 00:16:46 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-19 00:16:46 +0100 |
commit | 52242b03f1af7f73e73592c2e5ee2bc54813a64d (patch) | |
tree | 1ecafcbebad7b6f8ae71670afbe2921c975196fa /backend/tests/util/mod.rs | |
parent | 2dbb085008f68ed56675cf23ea6e1c89af632ea9 (diff) | |
download | planetwars.dev-52242b03f1af7f73e73592c2e5ee2bc54813a64d.tar.xz planetwars.dev-52242b03f1af7f73e73592c2e5ee2bc54813a64d.zip |
simple bot uploads
Diffstat (limited to 'backend/tests/util/mod.rs')
-rw-r--r-- | backend/tests/util/mod.rs | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/backend/tests/util/mod.rs b/backend/tests/util/mod.rs index 3502ddb..f34e9f3 100644 --- a/backend/tests/util/mod.rs +++ b/backend/tests/util/mod.rs @@ -2,7 +2,7 @@ use std::future::Future; use diesel::RunQueryDsl; use mozaic4_backend::DbConn; -use rocket::local::asynchronous::Client; +use rocket::{http::Header, local::asynchronous::Client}; // We use a lock to synchronize between tests so DB operations don't collide. // For now. In the future, we'll have a nice way to run each test in a DB @@ -11,9 +11,13 @@ static DB_LOCK: parking_lot::Mutex<()> = parking_lot::const_mutex(()); async fn reset_db(db: &DbConn) { db.run(|conn| { - diesel::sql_query("TRUNCATE TABLE users, sessions") - .execute(conn) - .expect("drop all tables"); + diesel::sql_query( + r#" + TRUNCATE TABLE users, sessions, + bots, code_bundles"#, + ) + .execute(conn) + .expect("drop all tables"); }) .await } @@ -37,3 +41,19 @@ where test_closure(client, db).await; } + +pub struct BearerAuth { + token: String, +} + +impl BearerAuth { + pub fn new(token: String) -> Self { + Self { token } + } +} + +impl<'a> Into<Header<'a>> for BearerAuth { + fn into(self) -> Header<'a> { + Header::new("Authorization", format!("Bearer {}", self.token)) + } +} |