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 delete and check tests

ToBinio da22de87 e083205e

+577 -414
+43
api/tests/common/client.rs
··· 1 1 use reqwest::{Response, header}; 2 2 use types::Todo; 3 + use uuid::Uuid; 3 4 4 5 pub struct Client { 5 6 pub api: reqwest::Client, ··· 33 34 34 35 pub async fn add_todo_json(&self, todo: serde_json::Value) -> Todo { 35 36 let response = self.add_todo(todo).await; 37 + assert_eq!(response.status().as_str(), "200"); 38 + response.json().await.unwrap() 39 + } 40 + 41 + pub async fn delete_todo(&self, todo_uuid: Uuid) -> Response { 42 + self.api 43 + .delete(&format!("{}/api/todos/{}", self.base_url, todo_uuid)) 44 + .send() 45 + .await 46 + .unwrap() 47 + } 48 + 49 + pub async fn delete_todo_json(&self, todo_uuid: Uuid) -> Todo { 50 + let response = self.delete_todo(todo_uuid).await; 51 + assert_eq!(response.status().as_str(), "200"); 52 + response.json().await.unwrap() 53 + } 54 + 55 + pub async fn check_todo(&self, todo_uuid: Uuid) -> Response { 56 + self.api 57 + .post(&format!("{}/api/todos/check/{}", self.base_url, todo_uuid)) 58 + .send() 59 + .await 60 + .unwrap() 61 + } 62 + 63 + pub async fn check_todo_json(&self, todo_uuid: Uuid) -> Todo { 64 + let response = self.check_todo(todo_uuid).await; 65 + assert_eq!(response.status().as_str(), "200"); 66 + response.json().await.unwrap() 67 + } 68 + 69 + pub async fn remove_check_todo(&self, todo_uuid: Uuid) -> Response { 70 + self.api 71 + .delete(&format!("{}/api/todos/check/{}", self.base_url, todo_uuid)) 72 + .send() 73 + .await 74 + .unwrap() 75 + } 76 + 77 + pub async fn remove_check_todo_json(&self, todo_uuid: Uuid) -> Todo { 78 + let response = self.remove_check_todo(todo_uuid).await; 36 79 assert_eq!(response.status().as_str(), "200"); 37 80 response.json().await.unwrap() 38 81 }
+5 -414
api/tests/todos.rs
··· 1 - use crate::common::db::clear_db; 2 - use common::client::get_client; 3 - use serde_json::json; 4 - use serial_test::serial; 5 - use types::Todo; 6 - use uuid::Uuid; 7 - 8 1 mod common; 9 2 10 - #[tokio::test] 11 - #[serial] 12 - async fn get_empty_todos() { 13 - let client = get_client(); 14 - clear_db().await; 15 - 16 - let response = client.get_todos().await; 17 - assert_eq!(response.status().as_str(), "200"); 18 - let json = response.json::<Vec<Todo>>().await.unwrap(); 19 - 20 - assert_eq!(json.len(), 0); 21 - } 22 - 23 - #[tokio::test] 24 - #[serial] 25 - async fn add_todo() { 26 - let client = get_client(); 27 - clear_db().await; 28 - 29 - let todo_uuid = Uuid::new_v4(); 30 - let todo = Todo { 31 - uuid: todo_uuid, 32 - title: "Test Todo".to_string(), 33 - note: "Test Note".to_string(), 34 - time: None, 35 - tags: vec![], 36 - category: None, 37 - checks: vec![], 38 - }; 39 - 40 - let response = client 41 - .add_todo(json!( 42 - { 43 - "data": { 44 - "uuid": todo_uuid, 45 - "title": "Test Todo", 46 - "note": "Test Note", 47 - "tags": [], 48 - "checks": [], 49 - } 50 - })) 51 - .await; 52 - 53 - assert_eq!(response.status().as_str(), "200"); 54 - 55 - let json = response.json::<Todo>().await.unwrap(); 56 - assert_eq!(json, todo); 57 - 58 - let todos = client.get_todos_json().await; 59 - assert_eq!(todos.len(), 1); 60 - assert_eq!(todos.first().unwrap(), &todo); 61 - } 62 - 63 - #[tokio::test] 64 - #[serial] 65 - async fn add_todo_with_labels() { 66 - let client = get_client(); 67 - clear_db().await; 68 - 69 - let todo_uuid = Uuid::new_v4(); 70 - let tag_uuid = Uuid::new_v4(); 71 - let category_uuid = Uuid::new_v4(); 72 - 73 - let todo = Todo { 74 - uuid: todo_uuid, 75 - title: "Test Todo".to_string(), 76 - note: "Test Note".to_string(), 77 - time: None, 78 - tags: vec![tag_uuid], 79 - category: Some(category_uuid), 80 - checks: vec![], 81 - }; 82 - 83 - let json = client 84 - .add_todo_json(json!( 85 - { 86 - "data": { 87 - "uuid": todo_uuid, 88 - "title": "Test Todo", 89 - "note": "Test Note", 90 - "tags": [tag_uuid], 91 - "category": category_uuid, 92 - "checks": [], 93 - } 94 - } 95 - )) 96 - .await; 97 - 98 - assert_eq!(json, todo); 99 - } 100 - 101 - #[tokio::test] 102 - #[serial] 103 - async fn add_mutliple_todos() { 104 - let client = get_client(); 105 - clear_db().await; 106 - 107 - let todo1_uuid = Uuid::new_v4(); 108 - let todo2_uuid = Uuid::new_v4(); 109 - let todo3_uuid = Uuid::new_v4(); 110 - 111 - client 112 - .add_todo_json(json!( 113 - { 114 - "data": { 115 - "uuid": todo1_uuid, 116 - "title": "Test Todo", 117 - "note": "Test Note", 118 - "tags": [], 119 - "checks": [], 120 - } 121 - } 122 - )) 123 - .await; 124 - client 125 - .add_todo_json(json!( 126 - { 127 - "data": { 128 - "uuid": todo2_uuid, 129 - "title": "Test Todo", 130 - "note": "Test Note", 131 - "tags": [], 132 - "checks": [], 133 - } 134 - } 135 - )) 136 - .await; 137 - client 138 - .add_todo_json(json!( 139 - { 140 - "data": { 141 - "uuid": todo3_uuid, 142 - "title": "Test Todo", 143 - "note": "Test Note", 144 - "tags": [], 145 - "checks": [], 146 - } 147 - } 148 - )) 149 - .await; 150 - 151 - let todos = client.get_todos_json().await; 152 - 153 - assert_eq!(todos.len(), 3); 154 - assert_eq!(todos[2].uuid, todo1_uuid); 155 - assert_eq!(todos[1].uuid, todo2_uuid); 156 - assert_eq!(todos[0].uuid, todo3_uuid); 157 - } 158 - 159 - #[tokio::test] 160 - #[serial] 161 - async fn add_mutliple_bottom_todos() { 162 - let client = get_client(); 163 - clear_db().await; 164 - 165 - let todo1_uuid = Uuid::new_v4(); 166 - let todo2_uuid = Uuid::new_v4(); 167 - let todo3_uuid = Uuid::new_v4(); 168 - 169 - client 170 - .add_todo_json(json!( 171 - { 172 - "data": { 173 - "uuid": todo1_uuid, 174 - "title": "Test Todo", 175 - "note": "Test Note", 176 - "tags": [], 177 - "checks": [], 178 - }, 179 - "position": "bottom" 180 - } 181 - )) 182 - .await; 183 - client 184 - .add_todo_json(json!( 185 - { 186 - "data": { 187 - "uuid": todo2_uuid, 188 - "title": "Test Todo", 189 - "note": "Test Note", 190 - "tags": [], 191 - "checks": [], 192 - }, 193 - "position": "bottom" 194 - } 195 - )) 196 - .await; 197 - client 198 - .add_todo_json(json!( 199 - { 200 - "data": { 201 - "uuid": todo3_uuid, 202 - "title": "Test Todo", 203 - "note": "Test Note", 204 - "tags": [], 205 - "checks": [], 206 - }, 207 - "position": "bottom" 208 - } 209 - )) 210 - .await; 211 - 212 - let todos = client.get_todos_json().await; 213 - 214 - assert_eq!(todos.len(), 3); 215 - assert_eq!(todos[0].uuid, todo1_uuid); 216 - assert_eq!(todos[1].uuid, todo2_uuid); 217 - assert_eq!(todos[2].uuid, todo3_uuid); 218 - } 219 - 220 - #[tokio::test] 221 - #[serial] 222 - async fn add_mutliple_top_todos() { 223 - let client = get_client(); 224 - clear_db().await; 225 - 226 - let todo1_uuid = Uuid::new_v4(); 227 - let todo2_uuid = Uuid::new_v4(); 228 - let todo3_uuid = Uuid::new_v4(); 229 - 230 - client 231 - .add_todo_json(json!( 232 - { 233 - "data": { 234 - "uuid": todo1_uuid, 235 - "title": "Test Todo", 236 - "note": "Test Note", 237 - "tags": [], 238 - "checks": [], 239 - }, 240 - "position": "top" 241 - } 242 - )) 243 - .await; 244 - client 245 - .add_todo_json(json!( 246 - { 247 - "data": { 248 - "uuid": todo2_uuid, 249 - "title": "Test Todo", 250 - "note": "Test Note", 251 - "tags": [], 252 - "checks": [], 253 - }, 254 - "position": "top" 255 - } 256 - )) 257 - .await; 258 - client 259 - .add_todo_json(json!( 260 - { 261 - "data": { 262 - "uuid": todo3_uuid, 263 - "title": "Test Todo", 264 - "note": "Test Note", 265 - "tags": [], 266 - "checks": [], 267 - }, 268 - "position": "top" 269 - } 270 - )) 271 - .await; 272 - 273 - let todos = client.get_todos_json().await; 274 - 275 - assert_eq!(todos.len(), 3); 276 - assert_eq!(todos[2].uuid, todo1_uuid); 277 - assert_eq!(todos[1].uuid, todo2_uuid); 278 - assert_eq!(todos[0].uuid, todo3_uuid); 279 - } 280 - 281 - #[tokio::test] 282 - #[serial] 283 - async fn add_mutliple_mixed_todos() { 284 - let client = get_client(); 285 - clear_db().await; 286 - 287 - let todo1_uuid = Uuid::new_v4(); 288 - let todo2_uuid = Uuid::new_v4(); 289 - let todo3_uuid = Uuid::new_v4(); 290 - 291 - client 292 - .add_todo_json(json!( 293 - { 294 - "data": { 295 - "uuid": todo1_uuid, 296 - "title": "Test Todo", 297 - "note": "Test Note", 298 - "tags": [], 299 - "checks": [], 300 - } 301 - } 302 - )) 303 - .await; 304 - client 305 - .add_todo_json(json!( 306 - { 307 - "data": { 308 - "uuid": todo2_uuid, 309 - "title": "Test Todo", 310 - "note": "Test Note", 311 - "tags": [], 312 - "checks": [], 313 - }, 314 - "position": "bottom" 315 - } 316 - )) 317 - .await; 318 - client 319 - .add_todo_json(json!( 320 - { 321 - "data": { 322 - "uuid": todo3_uuid, 323 - "title": "Test Todo", 324 - "note": "Test Note", 325 - "tags": [], 326 - "checks": [], 327 - }, 328 - "position": "top" 329 - } 330 - )) 331 - .await; 332 - 333 - let todos = client.get_todos_json().await; 334 - 335 - assert_eq!(todos.len(), 3); 336 - assert_eq!(todos[0].uuid, todo3_uuid); 337 - assert_eq!(todos[1].uuid, todo1_uuid); 338 - assert_eq!(todos[2].uuid, todo2_uuid); 339 - } 340 - 341 - #[tokio::test] 342 - #[serial] 343 - async fn add_mutliple_reverencing_todos() { 344 - let client = get_client(); 345 - clear_db().await; 346 - 347 - let todo1_uuid = Uuid::new_v4(); 348 - let todo2_uuid = Uuid::new_v4(); 349 - let todo3_uuid = Uuid::new_v4(); 350 - let todo4_uuid = Uuid::new_v4(); 351 - 352 - client 353 - .add_todo_json(json!( 354 - { 355 - "data": { 356 - "uuid": todo1_uuid, 357 - "title": "Test Todo", 358 - "note": "Test Note", 359 - "tags": [], 360 - "checks": [], 361 - } 362 - } 363 - )) 364 - .await; 365 - client 366 - .add_todo_json(json!( 367 - { 368 - "data": { 369 - "uuid": todo2_uuid, 370 - "title": "Test Todo", 371 - "note": "Test Note", 372 - "tags": [], 373 - "checks": [], 374 - "previousId": todo1_uuid 375 - } 376 - } 377 - )) 378 - .await; 379 - client 380 - .add_todo_json(json!( 381 - { 382 - "data": { 383 - "uuid": todo3_uuid, 384 - "title": "Test Todo", 385 - "note": "Test Note", 386 - "tags": [], 387 - "checks": [], 388 - }, 389 - "position": "top", 390 - "previousId": todo1_uuid 391 - } 392 - )) 393 - .await; 394 - client 395 - .add_todo_json(json!( 396 - { 397 - "data": { 398 - "uuid": todo4_uuid, 399 - "title": "Test Todo", 400 - "note": "Test Note", 401 - "tags": [], 402 - "checks": [], 403 - }, 404 - "position": "bottom", 405 - "previousId": todo3_uuid 406 - } 407 - )) 408 - .await; 409 - 410 - let todos = client.get_todos_json().await; 411 - 412 - assert_eq!(todos.len(), 4); 413 - assert_eq!(todos[0].uuid, todo2_uuid); 414 - assert_eq!(todos[1].uuid, todo3_uuid); 415 - assert_eq!(todos[2].uuid, todo4_uuid); 416 - assert_eq!(todos[3].uuid, todo1_uuid); 3 + mod todos { 4 + mod add; 5 + mod check; 6 + mod delete; 7 + mod get; 417 8 }
+401
api/tests/todos/add.rs
··· 1 + use crate::common::{client::get_client, db::clear_db}; 2 + use serde_json::json; 3 + use serial_test::serial; 4 + use types::Todo; 5 + use uuid::Uuid; 6 + 7 + #[tokio::test] 8 + #[serial] 9 + async fn add_todo() { 10 + let client = get_client(); 11 + clear_db().await; 12 + 13 + let todo_uuid = Uuid::new_v4(); 14 + let todo = Todo { 15 + uuid: todo_uuid, 16 + title: "Test Todo".to_string(), 17 + note: "Test Note".to_string(), 18 + time: None, 19 + tags: vec![], 20 + category: None, 21 + checks: vec![], 22 + }; 23 + 24 + let response = client 25 + .add_todo(json!( 26 + { 27 + "data": { 28 + "uuid": todo_uuid, 29 + "title": "Test Todo", 30 + "note": "Test Note", 31 + "tags": [], 32 + "checks": [], 33 + } 34 + })) 35 + .await; 36 + 37 + assert_eq!(response.status().as_str(), "200"); 38 + 39 + let json = response.json::<Todo>().await.unwrap(); 40 + assert_eq!(json, todo); 41 + 42 + let todos = client.get_todos_json().await; 43 + assert_eq!(todos.len(), 1); 44 + assert_eq!(todos.first().unwrap(), &todo); 45 + } 46 + 47 + #[tokio::test] 48 + #[serial] 49 + async fn add_todo_with_labels() { 50 + let client = get_client(); 51 + clear_db().await; 52 + 53 + let todo_uuid = Uuid::new_v4(); 54 + let tag_uuid = Uuid::new_v4(); 55 + let category_uuid = Uuid::new_v4(); 56 + 57 + let todo = Todo { 58 + uuid: todo_uuid, 59 + title: "Test Todo".to_string(), 60 + note: "Test Note".to_string(), 61 + time: None, 62 + tags: vec![tag_uuid], 63 + category: Some(category_uuid), 64 + checks: vec![], 65 + }; 66 + 67 + let json = client 68 + .add_todo_json(json!( 69 + { 70 + "data": { 71 + "uuid": todo_uuid, 72 + "title": "Test Todo", 73 + "note": "Test Note", 74 + "tags": [tag_uuid], 75 + "category": category_uuid, 76 + "checks": [], 77 + } 78 + } 79 + )) 80 + .await; 81 + 82 + assert_eq!(json, todo); 83 + } 84 + 85 + #[tokio::test] 86 + #[serial] 87 + async fn add_mutliple_todos() { 88 + let client = get_client(); 89 + clear_db().await; 90 + 91 + let todo1_uuid = Uuid::new_v4(); 92 + let todo2_uuid = Uuid::new_v4(); 93 + let todo3_uuid = Uuid::new_v4(); 94 + 95 + client 96 + .add_todo_json(json!( 97 + { 98 + "data": { 99 + "uuid": todo1_uuid, 100 + "title": "Test Todo", 101 + "note": "Test Note", 102 + "tags": [], 103 + "checks": [], 104 + } 105 + } 106 + )) 107 + .await; 108 + client 109 + .add_todo_json(json!( 110 + { 111 + "data": { 112 + "uuid": todo2_uuid, 113 + "title": "Test Todo", 114 + "note": "Test Note", 115 + "tags": [], 116 + "checks": [], 117 + } 118 + } 119 + )) 120 + .await; 121 + client 122 + .add_todo_json(json!( 123 + { 124 + "data": { 125 + "uuid": todo3_uuid, 126 + "title": "Test Todo", 127 + "note": "Test Note", 128 + "tags": [], 129 + "checks": [], 130 + } 131 + } 132 + )) 133 + .await; 134 + 135 + let todos = client.get_todos_json().await; 136 + 137 + assert_eq!(todos.len(), 3); 138 + assert_eq!(todos[2].uuid, todo1_uuid); 139 + assert_eq!(todos[1].uuid, todo2_uuid); 140 + assert_eq!(todos[0].uuid, todo3_uuid); 141 + } 142 + 143 + #[tokio::test] 144 + #[serial] 145 + async fn add_mutliple_bottom_todos() { 146 + let client = get_client(); 147 + clear_db().await; 148 + 149 + let todo1_uuid = Uuid::new_v4(); 150 + let todo2_uuid = Uuid::new_v4(); 151 + let todo3_uuid = Uuid::new_v4(); 152 + 153 + client 154 + .add_todo_json(json!( 155 + { 156 + "data": { 157 + "uuid": todo1_uuid, 158 + "title": "Test Todo", 159 + "note": "Test Note", 160 + "tags": [], 161 + "checks": [], 162 + }, 163 + "position": "bottom" 164 + } 165 + )) 166 + .await; 167 + client 168 + .add_todo_json(json!( 169 + { 170 + "data": { 171 + "uuid": todo2_uuid, 172 + "title": "Test Todo", 173 + "note": "Test Note", 174 + "tags": [], 175 + "checks": [], 176 + }, 177 + "position": "bottom" 178 + } 179 + )) 180 + .await; 181 + client 182 + .add_todo_json(json!( 183 + { 184 + "data": { 185 + "uuid": todo3_uuid, 186 + "title": "Test Todo", 187 + "note": "Test Note", 188 + "tags": [], 189 + "checks": [], 190 + }, 191 + "position": "bottom" 192 + } 193 + )) 194 + .await; 195 + 196 + let todos = client.get_todos_json().await; 197 + 198 + assert_eq!(todos.len(), 3); 199 + assert_eq!(todos[0].uuid, todo1_uuid); 200 + assert_eq!(todos[1].uuid, todo2_uuid); 201 + assert_eq!(todos[2].uuid, todo3_uuid); 202 + } 203 + 204 + #[tokio::test] 205 + #[serial] 206 + async fn add_mutliple_top_todos() { 207 + let client = get_client(); 208 + clear_db().await; 209 + 210 + let todo1_uuid = Uuid::new_v4(); 211 + let todo2_uuid = Uuid::new_v4(); 212 + let todo3_uuid = Uuid::new_v4(); 213 + 214 + client 215 + .add_todo_json(json!( 216 + { 217 + "data": { 218 + "uuid": todo1_uuid, 219 + "title": "Test Todo", 220 + "note": "Test Note", 221 + "tags": [], 222 + "checks": [], 223 + }, 224 + "position": "top" 225 + } 226 + )) 227 + .await; 228 + client 229 + .add_todo_json(json!( 230 + { 231 + "data": { 232 + "uuid": todo2_uuid, 233 + "title": "Test Todo", 234 + "note": "Test Note", 235 + "tags": [], 236 + "checks": [], 237 + }, 238 + "position": "top" 239 + } 240 + )) 241 + .await; 242 + client 243 + .add_todo_json(json!( 244 + { 245 + "data": { 246 + "uuid": todo3_uuid, 247 + "title": "Test Todo", 248 + "note": "Test Note", 249 + "tags": [], 250 + "checks": [], 251 + }, 252 + "position": "top" 253 + } 254 + )) 255 + .await; 256 + 257 + let todos = client.get_todos_json().await; 258 + 259 + assert_eq!(todos.len(), 3); 260 + assert_eq!(todos[2].uuid, todo1_uuid); 261 + assert_eq!(todos[1].uuid, todo2_uuid); 262 + assert_eq!(todos[0].uuid, todo3_uuid); 263 + } 264 + 265 + #[tokio::test] 266 + #[serial] 267 + async fn add_mutliple_mixed_todos() { 268 + let client = get_client(); 269 + clear_db().await; 270 + 271 + let todo1_uuid = Uuid::new_v4(); 272 + let todo2_uuid = Uuid::new_v4(); 273 + let todo3_uuid = Uuid::new_v4(); 274 + 275 + client 276 + .add_todo_json(json!( 277 + { 278 + "data": { 279 + "uuid": todo1_uuid, 280 + "title": "Test Todo", 281 + "note": "Test Note", 282 + "tags": [], 283 + "checks": [], 284 + } 285 + } 286 + )) 287 + .await; 288 + client 289 + .add_todo_json(json!( 290 + { 291 + "data": { 292 + "uuid": todo2_uuid, 293 + "title": "Test Todo", 294 + "note": "Test Note", 295 + "tags": [], 296 + "checks": [], 297 + }, 298 + "position": "bottom" 299 + } 300 + )) 301 + .await; 302 + client 303 + .add_todo_json(json!( 304 + { 305 + "data": { 306 + "uuid": todo3_uuid, 307 + "title": "Test Todo", 308 + "note": "Test Note", 309 + "tags": [], 310 + "checks": [], 311 + }, 312 + "position": "top" 313 + } 314 + )) 315 + .await; 316 + 317 + let todos = client.get_todos_json().await; 318 + 319 + assert_eq!(todos.len(), 3); 320 + assert_eq!(todos[0].uuid, todo3_uuid); 321 + assert_eq!(todos[1].uuid, todo1_uuid); 322 + assert_eq!(todos[2].uuid, todo2_uuid); 323 + } 324 + 325 + #[tokio::test] 326 + #[serial] 327 + async fn add_mutliple_referencing_todos() { 328 + let client = get_client(); 329 + clear_db().await; 330 + 331 + let todo1_uuid = Uuid::new_v4(); 332 + let todo2_uuid = Uuid::new_v4(); 333 + let todo3_uuid = Uuid::new_v4(); 334 + let todo4_uuid = Uuid::new_v4(); 335 + 336 + client 337 + .add_todo_json(json!( 338 + { 339 + "data": { 340 + "uuid": todo1_uuid, 341 + "title": "Test Todo", 342 + "note": "Test Note", 343 + "tags": [], 344 + "checks": [], 345 + } 346 + } 347 + )) 348 + .await; 349 + client 350 + .add_todo_json(json!( 351 + { 352 + "data": { 353 + "uuid": todo2_uuid, 354 + "title": "Test Todo", 355 + "note": "Test Note", 356 + "tags": [], 357 + "checks": [], 358 + "previousId": todo1_uuid 359 + } 360 + } 361 + )) 362 + .await; 363 + client 364 + .add_todo_json(json!( 365 + { 366 + "data": { 367 + "uuid": todo3_uuid, 368 + "title": "Test Todo", 369 + "note": "Test Note", 370 + "tags": [], 371 + "checks": [], 372 + }, 373 + "position": "top", 374 + "previousId": todo1_uuid 375 + } 376 + )) 377 + .await; 378 + client 379 + .add_todo_json(json!( 380 + { 381 + "data": { 382 + "uuid": todo4_uuid, 383 + "title": "Test Todo", 384 + "note": "Test Note", 385 + "tags": [], 386 + "checks": [], 387 + }, 388 + "position": "bottom", 389 + "previousId": todo3_uuid 390 + } 391 + )) 392 + .await; 393 + 394 + let todos = client.get_todos_json().await; 395 + 396 + assert_eq!(todos.len(), 4); 397 + assert_eq!(todos[0].uuid, todo2_uuid); 398 + assert_eq!(todos[1].uuid, todo3_uuid); 399 + assert_eq!(todos[2].uuid, todo4_uuid); 400 + assert_eq!(todos[3].uuid, todo1_uuid); 401 + }
+76
api/tests/todos/check.rs
··· 1 + use crate::common::{client::get_client, db::clear_db}; 2 + use serde_json::json; 3 + use serial_test::serial; 4 + use types::Todo; 5 + use uuid::Uuid; 6 + 7 + #[tokio::test] 8 + #[serial] 9 + async fn check_todo() { 10 + let client = get_client(); 11 + clear_db().await; 12 + 13 + let todo_uuid = Uuid::new_v4(); 14 + client 15 + .add_todo_json(json!( 16 + { 17 + "data": { 18 + "uuid": todo_uuid, 19 + "title": "Test Todo", 20 + "note": "Test Note", 21 + "tags": [], 22 + "checks": [], 23 + } 24 + })) 25 + .await; 26 + 27 + let response = client.check_todo(todo_uuid).await; 28 + 29 + assert_eq!(response.status().as_str(), "200"); 30 + let todo: Todo = response.json().await.unwrap(); 31 + 32 + assert_eq!(todo.uuid, todo_uuid); 33 + assert_eq!(todo.checks.len(), 1); 34 + 35 + let todos = client.get_todos_json().await; 36 + assert_eq!(todos.len(), 1); 37 + assert_eq!(todos.first().unwrap().uuid, todo_uuid); 38 + assert_eq!(todos.first().unwrap().checks.len(), 1); 39 + } 40 + 41 + #[tokio::test] 42 + #[serial] 43 + async fn remove_check_todo() { 44 + let client = get_client(); 45 + clear_db().await; 46 + 47 + let todo_uuid = Uuid::new_v4(); 48 + client 49 + .add_todo_json(json!( 50 + { 51 + "data": { 52 + "uuid": todo_uuid, 53 + "title": "Test Todo", 54 + "note": "Test Note", 55 + "tags": [], 56 + "checks": [], 57 + } 58 + })) 59 + .await; 60 + 61 + let response = client.check_todo(todo_uuid).await; 62 + 63 + assert_eq!(response.status().as_str(), "200"); 64 + let todo: Todo = response.json().await.unwrap(); 65 + 66 + assert_eq!(todo.uuid, todo_uuid); 67 + assert_eq!(todo.checks.len(), 1); 68 + 69 + let response = client.remove_check_todo(todo_uuid).await; 70 + 71 + assert_eq!(response.status().as_str(), "200"); 72 + let todo: Todo = response.json().await.unwrap(); 73 + 74 + assert_eq!(todo.uuid, todo_uuid); 75 + assert_eq!(todo.checks.len(), 0); 76 + }
+36
api/tests/todos/delete.rs
··· 1 + use crate::common::{client::get_client, db::clear_db}; 2 + use serde_json::json; 3 + use serial_test::serial; 4 + use types::Todo; 5 + use uuid::Uuid; 6 + 7 + #[tokio::test] 8 + #[serial] 9 + async fn delete_todo() { 10 + let client = get_client(); 11 + clear_db().await; 12 + 13 + let todo_uuid = Uuid::new_v4(); 14 + client 15 + .add_todo_json(json!( 16 + { 17 + "data": { 18 + "uuid": todo_uuid, 19 + "title": "Test Todo", 20 + "note": "Test Note", 21 + "tags": [], 22 + "checks": [], 23 + } 24 + })) 25 + .await; 26 + 27 + let response = client.delete_todo(todo_uuid).await; 28 + 29 + assert_eq!(response.status().as_str(), "200"); 30 + let todo: Todo = response.json().await.unwrap(); 31 + 32 + assert_eq!(todo.uuid, todo_uuid); 33 + 34 + let todos = client.get_todos_json().await; 35 + assert_eq!(todos.len(), 0); 36 + }
+16
api/tests/todos/get.rs
··· 1 + use crate::common::{client::get_client, db::clear_db}; 2 + use serial_test::serial; 3 + use types::Todo; 4 + 5 + #[tokio::test] 6 + #[serial] 7 + async fn get_empty_todos() { 8 + let client = get_client(); 9 + clear_db().await; 10 + 11 + let response = client.get_todos().await; 12 + assert_eq!(response.status().as_str(), "200"); 13 + let json = response.json::<Vec<Todo>>().await.unwrap(); 14 + 15 + assert_eq!(json.len(), 0); 16 + }