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.

add missing update tests

tobinio b897c42c 16312907

+154
+1
api/tests/categories.rs
··· 5 5 mod delete; 6 6 mod get; 7 7 mod sse; 8 + mod update; 8 9 }
+79
api/tests/categories/update.rs
··· 1 + use crate::common::{client::get_client, db::clear_db}; 2 + use serde_json::json; 3 + use serial_test::serial; 4 + use types::HexColor; 5 + use uuid::Uuid; 6 + 7 + #[tokio::test] 8 + #[serial] 9 + async fn update_category() { 10 + let client = get_client(); 11 + clear_db(&client).await; 12 + 13 + let category_uuid = Uuid::new_v4(); 14 + client 15 + .add_category_json(json!( 16 + { 17 + "uuid": category_uuid, 18 + "name": "Test Category", 19 + "color": "#233212", 20 + "icon": "icon" 21 + } 22 + )) 23 + .await; 24 + 25 + client 26 + .add_category_json(json!( 27 + { 28 + "uuid": category_uuid, 29 + "name": "Updated Category", 30 + "color": "#000000", 31 + "icon": "updated icon" 32 + } 33 + )) 34 + .await; 35 + 36 + let categories = client.get_categories_json().await; 37 + assert_eq!(categories.len(), 1); 38 + assert_eq!(categories[0].uuid, category_uuid); 39 + assert_eq!(categories[0].name, "Updated Category"); 40 + assert_eq!(categories[0].color, HexColor::from_str("#000000").unwrap()); 41 + assert_eq!(categories[0].icon, "updated icon"); 42 + } 43 + 44 + #[tokio::test] 45 + #[serial] 46 + async fn update_invalid_category() { 47 + let client = get_client(); 48 + clear_db(&client).await; 49 + 50 + let category_uuid = Uuid::new_v4(); 51 + client 52 + .add_category_json(json!( 53 + { 54 + "uuid": category_uuid, 55 + "name": "Test Category", 56 + "color": "#233212", 57 + "icon": "icon" 58 + } 59 + )) 60 + .await; 61 + 62 + let response = client 63 + .add_category(json!( 64 + { 65 + "uuid": category_uuid, 66 + "name": "Updated Category", 67 + "color": "#233212", 68 + } 69 + )) 70 + .await; 71 + assert_eq!(response.status().as_str(), "400"); 72 + 73 + let categories = client.get_categories_json().await; 74 + assert_eq!(categories.len(), 1); 75 + assert_eq!(categories[0].uuid, category_uuid); 76 + assert_eq!(categories[0].name, "Test Category"); 77 + assert_eq!(categories[0].color, HexColor::from_str("#233212").unwrap()); 78 + assert_eq!(categories[0].icon, "icon"); 79 + }
+1
api/tests/tags.rs
··· 5 5 mod delete; 6 6 mod get; 7 7 mod sse; 8 + mod update; 8 9 }
+73
api/tests/tags/update.rs
··· 1 + use crate::common::{client::get_client, db::clear_db}; 2 + use serde_json::json; 3 + use serial_test::serial; 4 + use types::HexColor; 5 + use uuid::Uuid; 6 + 7 + #[tokio::test] 8 + #[serial] 9 + async fn update_tag() { 10 + let client = get_client(); 11 + clear_db(&client).await; 12 + 13 + let tag_uuid = Uuid::new_v4(); 14 + client 15 + .add_tag_json(json!( 16 + { 17 + "uuid": tag_uuid, 18 + "name": "Test Tag", 19 + "color": "#233212", 20 + } 21 + )) 22 + .await; 23 + 24 + client 25 + .add_tag_json(json!( 26 + { 27 + "uuid": tag_uuid, 28 + "name": "Updated Tag", 29 + "color": "#000000", 30 + } 31 + )) 32 + .await; 33 + 34 + let tags = client.get_tags_json().await; 35 + assert_eq!(tags.len(), 1); 36 + assert_eq!(tags[0].uuid, tag_uuid); 37 + assert_eq!(tags[0].name, "Updated Tag"); 38 + assert_eq!(tags[0].color, HexColor::from_str("#000000").unwrap()); 39 + } 40 + 41 + #[tokio::test] 42 + #[serial] 43 + async fn update_invalid_tag() { 44 + let client = get_client(); 45 + clear_db(&client).await; 46 + 47 + let tag_uuid = Uuid::new_v4(); 48 + client 49 + .add_tag_json(json!( 50 + { 51 + "uuid": tag_uuid, 52 + "name": "Test Tag", 53 + "color": "#233212", 54 + } 55 + )) 56 + .await; 57 + 58 + let response = client 59 + .add_tag(json!( 60 + { 61 + "uuid": tag_uuid, 62 + "name": "Updated Tag", 63 + } 64 + )) 65 + .await; 66 + assert_eq!(response.status().as_str(), "400"); 67 + 68 + let tags = client.get_tags_json().await; 69 + assert_eq!(tags.len(), 1); 70 + assert_eq!(tags[0].uuid, tag_uuid); 71 + assert_eq!(tags[0].name, "Test Tag"); 72 + assert_eq!(tags[0].color, HexColor::from_str("#233212").unwrap()); 73 + }