A simple to-do app focused on tasks that can be completed within a specific time span.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

clear db for tests

tobinio 449386bb 049df332

+74 -52
+20 -7
api/src/main.rs
··· 1 - use axum::Router; 1 + use axum::{Router, extract::State, routing::post}; 2 2 use color_eyre::eyre; 3 + use http::StatusCode; 3 4 use migration::{Migrator, MigratorTrait}; 4 5 use sea_orm::{ConnectionTrait, Database, DatabaseConnection}; 5 6 use std::env; 6 7 use tower_http::trace::{self, TraceLayer}; 7 - use tracing::Level; 8 + use tracing::{Level, info}; 8 9 9 10 mod auth; 10 11 mod entities; ··· 28 29 29 30 let state = AppState { db_connection }; 30 31 31 - let app = Router::new().nest("/api", routes::routes(state)).layer( 32 - TraceLayer::new_for_http() 33 - .make_span_with(trace::DefaultMakeSpan::new().level(Level::INFO)) 34 - .on_response(trace::DefaultOnResponse::new().level(Level::INFO)), 35 - ); 32 + let app = Router::new() 33 + .route("/reset_db", post(reset_db)) 34 + .with_state(state.clone()) 35 + .nest("/api", routes::routes(state.clone())) 36 + .layer( 37 + TraceLayer::new_for_http() 38 + .make_span_with(trace::DefaultMakeSpan::new().level(Level::INFO)) 39 + .on_response(trace::DefaultOnResponse::new().level(Level::INFO)), 40 + ); 36 41 37 42 let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{port}")) 38 43 .await ··· 56 61 57 62 Ok(connection) 58 63 } 64 + 65 + // TODO: Remove 66 + async fn reset_db(state: State<AppState>) -> (StatusCode, &'static str) { 67 + let response = Migrator::fresh(&state.db_connection).await; 68 + info!(?response); 69 + 70 + (StatusCode::OK, "failed to fetch tags") 71 + }
+2 -2
api/tests/categories/add.rs
··· 8 8 #[serial] 9 9 async fn add_category() { 10 10 let client = get_client(); 11 - clear_db().await; 11 + clear_db(&client).await; 12 12 13 13 let category_uuid = Uuid::new_v4(); 14 14 let category = Category { ··· 43 43 #[serial] 44 44 async fn add_invalid_category() { 45 45 let client = get_client(); 46 - clear_db().await; 46 + clear_db(&client).await; 47 47 48 48 let category_uuid = Uuid::new_v4(); 49 49 let response = client
+2 -2
api/tests/categories/delete.rs
··· 8 8 #[serial] 9 9 async fn delete_category() { 10 10 let client = get_client(); 11 - clear_db().await; 11 + clear_db(&client).await; 12 12 13 13 let category_uuid = Uuid::new_v4(); 14 14 client ··· 36 36 #[serial] 37 37 async fn delete_unknown_category() { 38 38 let client = get_client(); 39 - clear_db().await; 39 + clear_db(&client).await; 40 40 41 41 let category_uuid = Uuid::new_v4(); 42 42 let response = client.delete_category(category_uuid).await;
+1 -1
api/tests/categories/get.rs
··· 6 6 #[serial] 7 7 async fn get_empty_categories() { 8 8 let client = get_client(); 9 - clear_db().await; 9 + clear_db(&client).await; 10 10 11 11 let response = client.get_categories().await; 12 12 assert_eq!(response.status().as_str(), "200");
+3 -3
api/tests/categories/sse.rs
··· 41 41 #[serial] 42 42 async fn sends_events_on_add() { 43 43 let client = get_client(); 44 - clear_db().await; 44 + clear_db(&client).await; 45 45 46 46 let handle = get_categories().await; 47 47 ··· 70 70 #[serial] 71 71 async fn sends_events_on_update() { 72 72 let client = get_client(); 73 - clear_db().await; 73 + clear_db(&client).await; 74 74 75 75 let category_uuid = Uuid::new_v4(); 76 76 client ··· 108 108 #[serial] 109 109 async fn sends_events_on_remove() { 110 110 let client = get_client(); 111 - clear_db().await; 111 + clear_db(&client).await; 112 112 113 113 let category_uuid = Uuid::new_v4(); 114 114 client
+10 -1
api/tests/common/db.rs
··· 2 2 3 3 use tokio::fs; 4 4 5 - pub async fn clear_db() { 5 + use crate::common::client::Client; 6 + 7 + pub async fn clear_db(client: &Client) { 6 8 let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../.data"); 7 9 8 10 if path.join("categories").exists() { ··· 14 16 if path.join("todos").exists() { 15 17 fs::remove_dir_all(path.join("todos")).await.unwrap(); 16 18 } 19 + 20 + client 21 + .api 22 + .post(&format!("{}/reset_db", client.base_url)) 23 + .send() 24 + .await 25 + .unwrap(); 17 26 }
+2 -2
api/tests/tags/add.rs
··· 8 8 #[serial] 9 9 async fn add_tag() { 10 10 let client = get_client(); 11 - clear_db().await; 11 + clear_db(&client).await; 12 12 13 13 let tag_uuid = Uuid::new_v4(); 14 14 let tag = Tag { ··· 41 41 #[serial] 42 42 async fn add_invalid_tag() { 43 43 let client = get_client(); 44 - clear_db().await; 44 + clear_db(&client).await; 45 45 46 46 let tag_uuid = Uuid::new_v4(); 47 47 let response = client
+2 -2
api/tests/tags/delete.rs
··· 8 8 #[serial] 9 9 async fn delete_tag() { 10 10 let client = get_client(); 11 - clear_db().await; 11 + clear_db(&client).await; 12 12 13 13 let tag_uuid = Uuid::new_v4(); 14 14 client ··· 35 35 #[serial] 36 36 async fn delete_unknown_tag() { 37 37 let client = get_client(); 38 - clear_db().await; 38 + clear_db(&client).await; 39 39 40 40 let tag_uuid = Uuid::new_v4(); 41 41 let response = client.delete_tag(tag_uuid).await;
+1 -1
api/tests/tags/get.rs
··· 6 6 #[serial] 7 7 async fn get_empty_tags() { 8 8 let client = get_client(); 9 - clear_db().await; 9 + clear_db(&client).await; 10 10 11 11 let response = client.get_tags().await; 12 12 assert_eq!(response.status().as_str(), "200");
+3 -3
api/tests/tags/sse.rs
··· 41 41 #[serial] 42 42 async fn sends_events_on_add() { 43 43 let client = get_client(); 44 - clear_db().await; 44 + clear_db(&client).await; 45 45 46 46 let handle = get_tags().await; 47 47 ··· 69 69 #[serial] 70 70 async fn sends_events_on_update() { 71 71 let client = get_client(); 72 - clear_db().await; 72 + clear_db(&client).await; 73 73 74 74 let tag_uuid = Uuid::new_v4(); 75 75 client ··· 106 106 #[serial] 107 107 async fn sends_events_on_remove() { 108 108 let client = get_client(); 109 - clear_db().await; 109 + clear_db(&client).await; 110 110 111 111 let tag_uuid = Uuid::new_v4(); 112 112 client
+12 -12
api/tests/todos/add.rs
··· 9 9 #[serial] 10 10 async fn add_todo() { 11 11 let client = get_client(); 12 - clear_db().await; 12 + clear_db(&client).await; 13 13 14 14 let todo_uuid = Uuid::new_v4(); 15 15 let todo = Todo { ··· 49 49 #[serial] 50 50 async fn add_todo_with_point_time() { 51 51 let client = get_client(); 52 - clear_db().await; 52 + clear_db(&client).await; 53 53 54 54 let todo_uuid = Uuid::new_v4(); 55 55 let todo = Todo { ··· 104 104 #[serial] 105 105 async fn add_todo_with_point_range() { 106 106 let client = get_client(); 107 - clear_db().await; 107 + clear_db(&client).await; 108 108 109 109 let todo_uuid = Uuid::new_v4(); 110 110 let todo = Todo { ··· 156 156 #[serial] 157 157 async fn add_todo_with_point_recurring_weekly() { 158 158 let client = get_client(); 159 - clear_db().await; 159 + clear_db(&client).await; 160 160 161 161 let todo_uuid = Uuid::new_v4(); 162 162 let todo = Todo { ··· 206 206 #[serial] 207 207 async fn add_todo_with_point_recurring_daily() { 208 208 let client = get_client(); 209 - clear_db().await; 209 + clear_db(&client).await; 210 210 211 211 let todo_uuid = Uuid::new_v4(); 212 212 let todo = Todo { ··· 254 254 #[serial] 255 255 async fn add_invalid_todo() { 256 256 let client = get_client(); 257 - clear_db().await; 257 + clear_db(&client).await; 258 258 259 259 let todo_uuid = Uuid::new_v4(); 260 260 let response = client ··· 302 302 #[serial] 303 303 async fn add_todo_with_labels() { 304 304 let client = get_client(); 305 - clear_db().await; 305 + clear_db(&client).await; 306 306 307 307 let todo_uuid = Uuid::new_v4(); 308 308 let tag_uuid = Uuid::new_v4(); ··· 340 340 #[serial] 341 341 async fn add_mutliple_todos() { 342 342 let client = get_client(); 343 - clear_db().await; 343 + clear_db(&client).await; 344 344 345 345 let todo1_uuid = Uuid::new_v4(); 346 346 let todo2_uuid = Uuid::new_v4(); ··· 398 398 #[serial] 399 399 async fn add_mutliple_bottom_todos() { 400 400 let client = get_client(); 401 - clear_db().await; 401 + clear_db(&client).await; 402 402 403 403 let todo1_uuid = Uuid::new_v4(); 404 404 let todo2_uuid = Uuid::new_v4(); ··· 459 459 #[serial] 460 460 async fn add_mutliple_top_todos() { 461 461 let client = get_client(); 462 - clear_db().await; 462 + clear_db(&client).await; 463 463 464 464 let todo1_uuid = Uuid::new_v4(); 465 465 let todo2_uuid = Uuid::new_v4(); ··· 520 520 #[serial] 521 521 async fn add_mutliple_mixed_todos() { 522 522 let client = get_client(); 523 - clear_db().await; 523 + clear_db(&client).await; 524 524 525 525 let todo1_uuid = Uuid::new_v4(); 526 526 let todo2_uuid = Uuid::new_v4(); ··· 580 580 #[serial] 581 581 async fn add_mutliple_referencing_todos() { 582 582 let client = get_client(); 583 - clear_db().await; 583 + clear_db(&client).await; 584 584 585 585 let todo1_uuid = Uuid::new_v4(); 586 586 let todo2_uuid = Uuid::new_v4();
+4 -4
api/tests/todos/check.rs
··· 8 8 #[serial] 9 9 async fn check_todo() { 10 10 let client = get_client(); 11 - clear_db().await; 11 + clear_db(&client).await; 12 12 13 13 let todo_uuid = Uuid::new_v4(); 14 14 client ··· 42 42 #[serial] 43 43 async fn check_unknown_todo() { 44 44 let client = get_client(); 45 - clear_db().await; 45 + clear_db(&client).await; 46 46 47 47 let todo_uuid = Uuid::new_v4(); 48 48 let response = client.check_todo(todo_uuid).await; ··· 54 54 #[serial] 55 55 async fn remove_check_todo() { 56 56 let client = get_client(); 57 - clear_db().await; 57 + clear_db(&client).await; 58 58 59 59 let todo_uuid = Uuid::new_v4(); 60 60 client ··· 91 91 #[serial] 92 92 async fn remove_check_unknown_todo() { 93 93 let client = get_client(); 94 - clear_db().await; 94 + clear_db(&client).await; 95 95 96 96 let todo_uuid = Uuid::new_v4(); 97 97 let response = client.remove_check_todo(todo_uuid).await;
+2 -2
api/tests/todos/delete.rs
··· 8 8 #[serial] 9 9 async fn delete_todo() { 10 10 let client = get_client(); 11 - clear_db().await; 11 + clear_db(&client).await; 12 12 13 13 let todo_uuid = Uuid::new_v4(); 14 14 client ··· 39 39 #[serial] 40 40 async fn delete_unknown_todo() { 41 41 let client = get_client(); 42 - clear_db().await; 42 + clear_db(&client).await; 43 43 44 44 let todo_uuid = Uuid::new_v4(); 45 45 let response = client.delete_todo(todo_uuid).await;
+1 -1
api/tests/todos/get.rs
··· 6 6 #[serial] 7 7 async fn get_empty_todos() { 8 8 let client = get_client(); 9 - clear_db().await; 9 + clear_db(&client).await; 10 10 11 11 let response = client.get_todos().await; 12 12 assert_eq!(response.status().as_str(), "200");
+2 -2
api/tests/todos/postion.rs
··· 7 7 #[serial] 8 8 async fn move_todo() { 9 9 let client = get_client(); 10 - clear_db().await; 10 + clear_db(&client).await; 11 11 12 12 let todo1_uuid = Uuid::new_v4(); 13 13 let todo2_uuid = Uuid::new_v4(); ··· 88 88 #[serial] 89 89 async fn invalid_move_todo() { 90 90 let client = get_client(); 91 - clear_db().await; 91 + clear_db(&client).await; 92 92 93 93 let todo1_uuid = Uuid::new_v4(); 94 94 let todo2_uuid = Uuid::new_v4();
+5 -5
api/tests/todos/sse.rs
··· 41 41 #[serial] 42 42 async fn sends_events_on_add() { 43 43 let client = get_client(); 44 - clear_db().await; 44 + clear_db(&client).await; 45 45 46 46 let handle = get_todos().await; 47 47 ··· 71 71 #[serial] 72 72 async fn sends_events_on_update() { 73 73 let client = get_client(); 74 - clear_db().await; 74 + clear_db(&client).await; 75 75 76 76 let todo_uuid = Uuid::new_v4(); 77 77 client ··· 113 113 #[serial] 114 114 async fn sends_events_on_remove() { 115 115 let client = get_client(); 116 - clear_db().await; 116 + clear_db(&client).await; 117 117 118 118 let todo_uuid = Uuid::new_v4(); 119 119 client ··· 143 143 #[serial] 144 144 async fn sends_events_on_check() { 145 145 let client = get_client(); 146 - clear_db().await; 146 + clear_db(&client).await; 147 147 148 148 let todo_uuid = Uuid::new_v4(); 149 149 client ··· 173 173 #[serial] 174 174 async fn sends_events_on_check_remove() { 175 175 let client = get_client(); 176 - clear_db().await; 176 + clear_db(&client).await; 177 177 178 178 let todo_uuid = Uuid::new_v4(); 179 179 client
+2 -2
api/tests/todos/update.rs
··· 7 7 #[serial] 8 8 async fn update_todos() { 9 9 let client = get_client(); 10 - clear_db().await; 10 + clear_db(&client).await; 11 11 12 12 let todo_uuid = Uuid::new_v4(); 13 13 let tag_uuid = Uuid::new_v4(); ··· 53 53 #[serial] 54 54 async fn update_invalid_todos() { 55 55 let client = get_client(); 56 - clear_db().await; 56 + clear_db(&client).await; 57 57 58 58 let todo_uuid = Uuid::new_v4(); 59 59