Cargo fmt --all
Browse files at this commit1efe92446302b4c68ccefe1262b04d53e06766e6Parent: b660c8b- style
- cargo fmt --all
6 changed files +376 -106
- crates/dizey-core/src/accounts.rs +17 -7
- crates/dizey-core/src/auth.rs +13 -3
- crates/dizey-core/src/store/mod.rs +1 -1
- crates/dizey-core/src/store/turso_store.rs +50 -24
- crates/dizey-core/tests/store.rs +293 -69
- crates/dizey-web/src/main.rs +2 -2
crates/dizey-core/src/accounts.rsmodified+17 -7
| @@ -15,11 +15,9 @@ use std::sync::Arc; | ||
| 15 | 15 | |
| 16 | 16 | use time::{Duration, OffsetDateTime}; |
| 17 | 17 | |
| 18 | -use crate::auth::{ | |
| 19 | - self, AuthError, PasswordProblem, Token, hash_password, verify_password, | |
| 20 | -}; | |
| 21 | -use crate::store::{NewUser, Session, Store, StoreError, User, Workspace}; | |
| 22 | 18 | use crate::Role; |
| 19 | +use crate::auth::{self, AuthError, PasswordProblem, Token, hash_password, verify_password}; | |
| 20 | +use crate::store::{NewUser, Session, Store, StoreError, User, Workspace}; | |
| 23 | 21 | |
| 24 | 22 | /// How long a first-sign-in link is good for. The mockups say seven days, and |
| 25 | 23 | /// an expired link is not a dead account: resending opens the same one. |
| @@ -243,7 +241,11 @@ impl Accounts { | ||
| 243 | 241 | |
| 244 | 242 | self.store.set_password_hash(&user.id, &hash).await?; |
| 245 | 243 | self.store.clear_auth_attempts(&client_bucket).await?; |
| 246 | - let user = self.store.user(&user.id).await?.ok_or(StoreError::NotFound)?; | |
| 244 | + let user = self | |
| 245 | + .store | |
| 246 | + .user(&user.id) | |
| 247 | + .await? | |
| 248 | + .ok_or(StoreError::NotFound)?; | |
| 247 | 249 | self.start_session(user).await |
| 248 | 250 | } |
| 249 | 251 | |
| @@ -318,7 +320,11 @@ impl Accounts { | ||
| 318 | 320 | self.store |
| 319 | 321 | .record_auth_attempt(&client_bucket, OffsetDateTime::now_utc()) |
| 320 | 322 | .await?; |
| 321 | - let user = self.store.user(user_id).await?.ok_or(StoreError::NotFound)?; | |
| 323 | + let user = self | |
| 324 | + .store | |
| 325 | + .user(user_id) | |
| 326 | + .await? | |
| 327 | + .ok_or(StoreError::NotFound)?; | |
| 322 | 328 | let ok = match user.password_hash.as_deref() { |
| 323 | 329 | Some(stored) => verify_password(current, stored), |
| 324 | 330 | None => { |
| @@ -337,7 +343,11 @@ impl Accounts { | ||
| 337 | 343 | self.store |
| 338 | 344 | .revoke_sessions_for_user(&user.id, OffsetDateTime::now_utc()) |
| 339 | 345 | .await?; |
| 340 | - let user = self.store.user(&user.id).await?.ok_or(StoreError::NotFound)?; | |
| 346 | + let user = self | |
| 347 | + .store | |
| 348 | + .user(&user.id) | |
| 349 | + .await? | |
| 350 | + .ok_or(StoreError::NotFound)?; | |
| 341 | 351 | self.start_session(user).await |
| 342 | 352 | } |
| 343 | 353 |
crates/dizey-core/src/auth.rsmodified+13 -3
| @@ -66,7 +66,9 @@ pub fn hash_password(password: &str) -> Result<String, AuthError> { | ||
| 66 | 66 | /// the cost later does not lock anyone out. |
| 67 | 67 | pub fn verify_password(password: &str, phc: &str) -> bool { |
| 68 | 68 | match PasswordHash::new(phc) { |
| 69 | - Ok(parsed) => argon2().verify_password(password.as_bytes(), &parsed).is_ok(), | |
| 69 | + Ok(parsed) => argon2() | |
| 70 | + .verify_password(password.as_bytes(), &parsed) | |
| 71 | + .is_ok(), | |
| 70 | 72 | Err(_) => false, |
| 71 | 73 | } |
| 72 | 74 | } |
| @@ -146,7 +148,11 @@ fn hex(bytes: &[u8]) -> String { | ||
| 146 | 148 | } |
| 147 | 149 | |
| 148 | 150 | /// The rules the first-sign-in screen states, checked server-side. |
| 149 | -pub fn check_password(password: &str, email: &str, display_name: &str) -> Result<(), PasswordProblem> { | |
| 151 | +pub fn check_password( | |
| 152 | + password: &str, | |
| 153 | + email: &str, | |
| 154 | + display_name: &str, | |
| 155 | +) -> Result<(), PasswordProblem> { | |
| 150 | 156 | // Counted in characters, not bytes: a ten-character password is ten |
| 151 | 157 | // characters whatever alphabet it is in. |
| 152 | 158 | if password.chars().count() < 10 { |
| @@ -279,7 +285,11 @@ mod dummy_hash_generator { | ||
| 279 | 285 | #[test] |
| 280 | 286 | #[ignore = "generator, not a check"] |
| 281 | 287 | fn print_a_dummy_hash() { |
| 282 | - let token = format!("{}{}", super::Token::mint().expose(), super::Token::mint().expose()); | |
| 288 | + let token = format!( | |
| 289 | + "{}{}", | |
| 290 | + super::Token::mint().expose(), | |
| 291 | + super::Token::mint().expose() | |
| 292 | + ); | |
| 283 | 293 | println!("{}", super::hash_password(&token).unwrap()); |
| 284 | 294 | } |
| 285 | 295 | } |
crates/dizey-core/src/store/mod.rsmodified+1 -1
| @@ -8,9 +8,9 @@ use async_trait::async_trait; | ||
| 8 | 8 | use serde::{Deserialize, Serialize}; |
| 9 | 9 | use time::OffsetDateTime; |
| 10 | 10 | |
| 11 | +use crate::Role; | |
| 11 | 12 | use crate::board::{BoardReads, TaskRow}; |
| 12 | 13 | use crate::detail::{ActivityKind, DetailReads}; |
| 13 | -use crate::Role; | |
| 14 | 14 | |
| 15 | 15 | pub mod turso_store; |
| 16 | 16 |
crates/dizey-core/src/store/turso_store.rsmodified+50 -24
| @@ -57,10 +57,7 @@ impl TursoStore { | ||
| 57 | 57 | // (a second process, or a careless second open) fails outright with |
| 58 | 58 | // "database is locked" and silently drops the write unless a busy |
| 59 | 59 | // timeout is set. Both pragmas are set on every connection we hand out. |
| 60 | - for pragma in [ | |
| 61 | - "PRAGMA foreign_keys = ON", | |
| 62 | - "PRAGMA busy_timeout = 5000", | |
| 63 | - ] { | |
| 60 | + for pragma in ["PRAGMA foreign_keys = ON", "PRAGMA busy_timeout = 5000"] { | |
| 64 | 61 | conn.execute(pragma, ()).await.map_err(backend)?; |
| 65 | 62 | } |
| 66 | 63 | let store = Self { conn, db }; |
| @@ -112,7 +109,12 @@ impl TursoStore { | ||
| 112 | 109 | |
| 113 | 110 | /// The schema version the database is actually at. |
| 114 | 111 | pub async fn schema_version(&self) -> Result<i64> { |
| 115 | - Ok(self.applied_versions().await?.into_iter().max().unwrap_or(0)) | |
| 112 | + Ok(self | |
| 113 | + .applied_versions() | |
| 114 | + .await? | |
| 115 | + .into_iter() | |
| 116 | + .max() | |
| 117 | + .unwrap_or(0)) | |
| 116 | 118 | } |
| 117 | 119 | |
| 118 | 120 | /// A connection of its own, for work that opens a transaction. |
| @@ -191,9 +193,7 @@ fn opt_text(row: &Row, idx: usize) -> Result<Option<String>> { | ||
| 191 | 193 | } |
| 192 | 194 | |
| 193 | 195 | fn count_of(row: &Row) -> Result<u64> { |
| 194 | - row.get::<i64>(0) | |
| 195 | - .map_err(backend) | |
| 196 | - .map(|n| n.max(0) as u64) | |
| 196 | + row.get::<i64>(0).map_err(backend).map(|n| n.max(0) as u64) | |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | fn workspace_from(row: &Row) -> Result<Workspace> { |
| @@ -230,8 +230,7 @@ fn user_from(row: &Row) -> Result<User> { | ||
| 230 | 230 | workspace_id: text(row, 1)?, |
| 231 | 231 | email: text(row, 2)?, |
| 232 | 232 | display_name: text(row, 3)?, |
| 233 | - role: Role::parse(&text(row, 4)?) | |
| 234 | - .ok_or_else(|| StoreError::Corrupt("role".into()))?, | |
| 233 | + role: Role::parse(&text(row, 4)?).ok_or_else(|| StoreError::Corrupt("role".into()))?, | |
| 235 | 234 | password_hash: opt_text(row, 5)?, |
| 236 | 235 | photo_path: opt_text(row, 6)?, |
| 237 | 236 | created_at: parse_stamp(&text(row, 7)?)?, |
| @@ -463,7 +462,11 @@ impl Store for TursoStore { | ||
| 463 | 462 | |
| 464 | 463 | async fn create_user(&self, new: NewUser) -> Result<User> { |
| 465 | 464 | let email = fold_email(&new.email); |
| 466 | - if self.user_by_email(&new.workspace_id, &email).await?.is_some() { | |
| 465 | + if self | |
| 466 | + .user_by_email(&new.workspace_id, &email) | |
| 467 | + .await? | |
| 468 | + .is_some() | |
| 469 | + { | |
| 467 | 470 | return Err(StoreError::Conflict("account")); |
| 468 | 471 | } |
| 469 | 472 | let id = Uuid::new_v4().to_string(); |
| @@ -494,8 +497,7 @@ impl Store for TursoStore { | ||
| 494 | 497 | } |
| 495 | 498 | |
| 496 | 499 | async fn user_by_email(&self, workspace_id: &str, email: &str) -> Result<Option<User>> { |
| 497 | - let sql = | |
| 498 | - format!("SELECT {USER_COLUMNS} FROM user WHERE workspace_id = ?1 AND email = ?2"); | |
| 500 | + let sql = format!("SELECT {USER_COLUMNS} FROM user WHERE workspace_id = ?1 AND email = ?2"); | |
| 499 | 501 | match self |
| 500 | 502 | .one_row(&sql, params![workspace_id, fold_email(email)]) |
| 501 | 503 | .await? |
| @@ -509,7 +511,11 @@ impl Store for TursoStore { | ||
| 509 | 511 | let sql = format!( |
| 510 | 512 | "SELECT {USER_COLUMNS} FROM user WHERE workspace_id = ?1 ORDER BY created_at, id" |
| 511 | 513 | ); |
| 512 | - let mut rows = self.conn.query(&sql, params![workspace_id]).await.map_err(backend)?; | |
| 514 | + let mut rows = self | |
| 515 | + .conn | |
| 516 | + .query(&sql, params![workspace_id]) | |
| 517 | + .await | |
| 518 | + .map_err(backend)?; | |
| 513 | 519 | let mut out = Vec::new(); |
| 514 | 520 | while let Some(row) = rows.next().await.map_err(backend)? { |
| 515 | 521 | out.push(user_from(&row)?); |
| @@ -539,7 +545,11 @@ impl Store for TursoStore { | ||
| 539 | 545 | ) |
| 540 | 546 | .await |
| 541 | 547 | .map_err(backend)?; |
| 542 | - if n == 0 { Err(StoreError::NotFound) } else { Ok(()) } | |
| 548 | + if n == 0 { | |
| 549 | + Err(StoreError::NotFound) | |
| 550 | + } else { | |
| 551 | + Ok(()) | |
| 552 | + } | |
| 543 | 553 | } |
| 544 | 554 | |
| 545 | 555 | async fn set_profile( |
| @@ -560,7 +570,11 @@ impl Store for TursoStore { | ||
| 560 | 570 | ) |
| 561 | 571 | .await |
| 562 | 572 | .map_err(backend)?; |
| 563 | - if n == 0 { Err(StoreError::NotFound) } else { Ok(()) } | |
| 573 | + if n == 0 { | |
| 574 | + Err(StoreError::NotFound) | |
| 575 | + } else { | |
| 576 | + Ok(()) | |
| 577 | + } | |
| 564 | 578 | } |
| 565 | 579 | |
| 566 | 580 | async fn set_role(&self, user_id: &str, role: Role) -> Result<()> { |
| @@ -572,7 +586,11 @@ impl Store for TursoStore { | ||
| 572 | 586 | ) |
| 573 | 587 | .await |
| 574 | 588 | .map_err(backend)?; |
| 575 | - if n == 0 { Err(StoreError::NotFound) } else { Ok(()) } | |
| 589 | + if n == 0 { | |
| 590 | + Err(StoreError::NotFound) | |
| 591 | + } else { | |
| 592 | + Ok(()) | |
| 593 | + } | |
| 576 | 594 | } |
| 577 | 595 | |
| 578 | 596 | async fn mark_signed_in(&self, user_id: &str, at: OffsetDateTime) -> Result<()> { |
| @@ -584,7 +602,11 @@ impl Store for TursoStore { | ||
| 584 | 602 | ) |
| 585 | 603 | .await |
| 586 | 604 | .map_err(backend)?; |
| 587 | - if n == 0 { Err(StoreError::NotFound) } else { Ok(()) } | |
| 605 | + if n == 0 { | |
| 606 | + Err(StoreError::NotFound) | |
| 607 | + } else { | |
| 608 | + Ok(()) | |
| 609 | + } | |
| 588 | 610 | } |
| 589 | 611 | |
| 590 | 612 | async fn create_signin_link( |
| @@ -708,7 +730,11 @@ impl Store for TursoStore { | ||
| 708 | 730 | ) |
| 709 | 731 | .await |
| 710 | 732 | .map_err(backend)?; |
| 711 | - if n == 0 { Err(StoreError::NotFound) } else { Ok(()) } | |
| 733 | + if n == 0 { | |
| 734 | + Err(StoreError::NotFound) | |
| 735 | + } else { | |
| 736 | + Ok(()) | |
| 737 | + } | |
| 712 | 738 | } |
| 713 | 739 | |
| 714 | 740 | async fn revoke_sessions_for_user(&self, user_id: &str, at: OffsetDateTime) -> Result<u64> { |
| @@ -749,7 +775,10 @@ impl Store for TursoStore { | ||
| 749 | 775 | |
| 750 | 776 | async fn clear_auth_attempts(&self, bucket: &str) -> Result<()> { |
| 751 | 777 | self.conn |
| 752 | - .execute("DELETE FROM auth_attempt WHERE bucket = ?1", params![bucket]) | |
| 778 | + .execute( | |
| 779 | + "DELETE FROM auth_attempt WHERE bucket = ?1", | |
| 780 | + params![bucket], | |
| 781 | + ) | |
| 753 | 782 | .await |
| 754 | 783 | .map_err(backend)?; |
| 755 | 784 | Ok(()) |
| @@ -1362,10 +1391,7 @@ impl DetailReads for TursoStore { | ||
| 1362 | 1391 | Ok(out) |
| 1363 | 1392 | } |
| 1364 | 1393 | |
| 1365 | - async fn dependencies_for_task( | |
| 1366 | - &self, | |
| 1367 | - task_id: &str, | |
| 1368 | - ) -> Result<Vec<(bool, DependencyEdge)>> { | |
| 1394 | + async fn dependencies_for_task(&self, task_id: &str) -> Result<Vec<(bool, DependencyEdge)>> { | |
| 1369 | 1395 | // Both directions in one round trip: the leading column says which. |
| 1370 | 1396 | let mut rows = self |
| 1371 | 1397 | .conn |
crates/dizey-core/tests/store.rsmodified+293 -69
| @@ -6,9 +6,9 @@ | ||
| 6 | 6 | |
| 7 | 7 | use std::path::PathBuf; |
| 8 | 8 | |
| 9 | +use dizey_core::Role; | |
| 9 | 10 | use dizey_core::auth::{Token, hash_password}; |
| 10 | 11 | use dizey_core::store::{DeletePolicy, NewUser, Store, StoreError, TursoStore, User}; |
| 11 | -use dizey_core::Role; | |
| 12 | 12 | use time::{Duration, OffsetDateTime}; |
| 13 | 13 | use uuid::Uuid; |
| 14 | 14 | |
| @@ -129,7 +129,10 @@ async fn a_second_claim_loses_and_changes_nothing() { | ||
| 129 | 129 | assert!(matches!(second, Err(StoreError::AlreadyClaimed))); |
| 130 | 130 | |
| 131 | 131 | // The loser must not have joined as anything at all. |
| 132 | - assert_eq!(scratch.store.workspace().await.unwrap().unwrap().name, "Dizey"); | |
| 132 | + assert_eq!( | |
| 133 | + scratch.store.workspace().await.unwrap().unwrap().name, | |
| 134 | + "Dizey" | |
| 135 | + ); | |
| 133 | 136 | assert_eq!(scratch.store.count_users("").await.unwrap(), 0); |
| 134 | 137 | let ws_id = scratch.store.workspace().await.unwrap().unwrap().id; |
| 135 | 138 | assert_eq!(scratch.store.count_users(&ws_id).await.unwrap(), 1); |
| @@ -179,7 +182,11 @@ async fn concurrent_claims_produce_exactly_one_admin() { | ||
| 179 | 182 | assert_eq!(winners.len(), 1, "exactly one claim wins: {winners:?}"); |
| 180 | 183 | |
| 181 | 184 | let ws_id = store.workspace().await.unwrap().unwrap().id; |
| 182 | - assert_eq!(store.count_users(&ws_id).await.unwrap(), 1, "no half-written losers"); | |
| 185 | + assert_eq!( | |
| 186 | + store.count_users(&ws_id).await.unwrap(), | |
| 187 | + 1, | |
| 188 | + "no half-written losers" | |
| 189 | + ); | |
| 183 | 190 | let owner = store.owner().await.unwrap().unwrap(); |
| 184 | 191 | assert_eq!(owner.email, winners[0]); |
| 185 | 192 | |
| @@ -202,7 +209,10 @@ async fn workspace_defaults_match_the_settings_screen() { | ||
| 202 | 209 | .unwrap(); |
| 203 | 210 | assert_eq!(ws.attachment_limit_bytes, 25 * 1024 * 1024); |
| 204 | 211 | assert_eq!(ws.photo_limit_bytes, 2 * 1024 * 1024); |
| 205 | - assert!(ws.allowed_file_types.is_empty(), "every type until narrowed"); | |
| 212 | + assert!( | |
| 213 | + ws.allowed_file_types.is_empty(), | |
| 214 | + "every type until narrowed" | |
| 215 | + ); | |
| 206 | 216 | assert_eq!(ws.who_can_delete_tasks, DeletePolicy::Anyone); |
| 207 | 217 | assert!(ws.smtp_host.is_none()); |
| 208 | 218 | } |
| @@ -212,7 +222,15 @@ async fn smtp_password_is_never_part_of_the_workspace_record() { | ||
| 212 | 222 | let (scratch, ws_id, _) = workspace_with_admin().await; |
| 213 | 223 | scratch |
| 214 | 224 | .store |
| 215 | - .set_smtp(&ws_id, "smtp.fastmail.com", 465, "dizey", "hunter2", "Dizey", "dizey@dizey.sh") | |
| 225 | + .set_smtp( | |
| 226 | + &ws_id, | |
| 227 | + "smtp.fastmail.com", | |
| 228 | + 465, | |
| 229 | + "dizey", | |
| 230 | + "hunter2", | |
| 231 | + "Dizey", | |
| 232 | + "dizey@dizey.sh", | |
| 233 | + ) | |
| 216 | 234 | .await |
| 217 | 235 | .unwrap(); |
| 218 | 236 | |
| @@ -224,7 +242,12 @@ async fn smtp_password_is_never_part_of_the_workspace_record() { | ||
| 224 | 242 | let serialised = serde_json::to_string(&ws).unwrap(); |
| 225 | 243 | assert!(!serialised.contains("hunter2"), "{serialised}"); |
| 226 | 244 | assert_eq!( |
| 227 | - scratch.store.smtp_password(&ws_id).await.unwrap().as_deref(), | |
| 245 | + scratch | |
| 246 | + .store | |
| 247 | + .smtp_password(&ws_id) | |
| 248 | + .await | |
| 249 | + .unwrap() | |
| 250 | + .as_deref(), | |
| 228 | 251 | Some("hunter2") |
| 229 | 252 | ); |
| 230 | 253 | } |
| @@ -235,7 +258,13 @@ async fn limits_round_trip_including_the_file_type_list() { | ||
| 235 | 258 | let types = vec!["png".to_string(), "pdf".to_string()]; |
| 236 | 259 | scratch |
| 237 | 260 | .store |
| 238 | - .set_limits(&ws_id, 10 * 1024 * 1024, 512 * 1024, &types, DeletePolicy::Admin) | |
| 261 | + .set_limits( | |
| 262 | + &ws_id, | |
| 263 | + 10 * 1024 * 1024, | |
| 264 | + 512 * 1024, | |
| 265 | + &types, | |
| 266 | + DeletePolicy::Admin, | |
| 267 | + ) | |
| 239 | 268 | .await |
| 240 | 269 | .unwrap(); |
| 241 | 270 | let ws = scratch.store.workspace().await.unwrap().unwrap(); |
| @@ -329,10 +358,7 @@ async fn members_list_and_count_for_the_admin_screen() { | ||
| 329 | 358 | assert_eq!(scratch.store.count_users(&ws_id).await.unwrap(), 3); |
| 330 | 359 | let users = scratch.store.users(&ws_id).await.unwrap(); |
| 331 | 360 | assert_eq!(users[0].id, admin_id); |
| 332 | - assert_eq!( | |
| 333 | - users.iter().filter(|u| u.role == Role::Viewer).count(), | |
| 334 | - 1 | |
| 335 | - ); | |
| 361 | + assert_eq!(users.iter().filter(|u| u.role == Role::Viewer).count(), 1); | |
| 336 | 362 | } |
| 337 | 363 | |
| 338 | 364 | #[tokio::test] |
| @@ -354,7 +380,11 @@ async fn profile_and_role_updates_stick() { | ||
| 354 | 380 | .set_profile(&user.id, "Grace H.", Some("photos/grace.png")) |
| 355 | 381 | .await |
| 356 | 382 | .unwrap(); |
| 357 | - scratch.store.set_role(&user.id, Role::Viewer).await.unwrap(); | |
| 383 | + scratch | |
| 384 | + .store | |
| 385 | + .set_role(&user.id, Role::Viewer) | |
| 386 | + .await | |
| 387 | + .unwrap(); | |
| 358 | 388 | let at = OffsetDateTime::now_utc(); |
| 359 | 389 | scratch.store.mark_signed_in(&user.id, at).await.unwrap(); |
| 360 | 390 | |
| @@ -369,8 +399,21 @@ async fn profile_and_role_updates_stick() { | ||
| 369 | 399 | ); |
| 370 | 400 | |
| 371 | 401 | // Clearing the photo is a real update, not a no-op. |
| 372 | - scratch.store.set_profile(&user.id, "Grace H.", None).await.unwrap(); | |
| 373 | - assert!(scratch.store.user(&user.id).await.unwrap().unwrap().photo_path.is_none()); | |
| 402 | + scratch | |
| 403 | + .store | |
| 404 | + .set_profile(&user.id, "Grace H.", None) | |
| 405 | + .await | |
| 406 | + .unwrap(); | |
| 407 | + assert!( | |
| 408 | + scratch | |
| 409 | + .store | |
| 410 | + .user(&user.id) | |
| 411 | + .await | |
| 412 | + .unwrap() | |
| 413 | + .unwrap() | |
| 414 | + .photo_path | |
| 415 | + .is_none() | |
| 416 | + ); | |
| 374 | 417 | } |
| 375 | 418 | |
| 376 | 419 | #[tokio::test] |
| @@ -427,7 +470,13 @@ async fn a_signin_link_stores_only_the_hash_and_is_used_once() { | ||
| 427 | 470 | .is_none() |
| 428 | 471 | ); |
| 429 | 472 | |
| 430 | - assert!(scratch.store.consume_signin_link(&link.id, now).await.unwrap()); | |
| 473 | + assert!( | |
| 474 | + scratch | |
| 475 | + .store | |
| 476 | + .consume_signin_link(&link.id, now) | |
| 477 | + .await | |
| 478 | + .unwrap() | |
| 479 | + ); | |
| 431 | 480 | let used = scratch |
| 432 | 481 | .store |
| 433 | 482 | .signin_link_by_hash("hash-of-the-token") |
| @@ -436,7 +485,13 @@ async fn a_signin_link_stores_only_the_hash_and_is_used_once() { | ||
| 436 | 485 | .unwrap(); |
| 437 | 486 | assert!(!used.is_usable(now)); |
| 438 | 487 | // A second use finds nothing left to consume. |
| 439 | - assert!(!scratch.store.consume_signin_link(&link.id, now).await.unwrap()); | |
| 488 | + assert!( | |
| 489 | + !scratch | |
| 490 | + .store | |
| 491 | + .consume_signin_link(&link.id, now) | |
| 492 | + .await | |
| 493 | + .unwrap() | |
| 494 | + ); | |
| 440 | 495 | } |
| 441 | 496 | |
| 442 | 497 | #[tokio::test] |
| @@ -556,7 +611,11 @@ async fn a_session_lives_until_it_expires_or_is_revoked() { | ||
| 556 | 611 | Some(token.hash()) |
| 557 | 612 | ); |
| 558 | 613 | |
| 559 | - scratch.store.revoke_session(&session.id, now).await.unwrap(); | |
| 614 | + scratch | |
| 615 | + .store | |
| 616 | + .revoke_session(&session.id, now) | |
| 617 | + .await | |
| 618 | + .unwrap(); | |
| 560 | 619 | let revoked = scratch |
| 561 | 620 | .store |
| 562 | 621 | .session_by_hash(&token.hash()) |
| @@ -782,7 +841,12 @@ async fn the_claim_screen_enforces_its_own_password_rules() { | ||
| 782 | 841 | async fn a_second_claim_is_refused() { |
| 783 | 842 | let (_scratch, accounts, _admin) = claimed().await; |
| 784 | 843 | let second = accounts |
| 785 | - .claim_workspace("Theirs", "mallory@elsewhere.example", "Mallory", "tide-tables-1892") | |
| 844 | + .claim_workspace( | |
| 845 | + "Theirs", | |
| 846 | + "mallory@elsewhere.example", | |
| 847 | + "Mallory", | |
| 848 | + "tide-tables-1892", | |
| 849 | + ) | |
| 786 | 850 | .await; |
| 787 | 851 | assert!(matches!(second, Err(AccountError::AlreadyClaimed))); |
| 788 | 852 | } |
| @@ -795,7 +859,10 @@ async fn an_invited_member_chooses_their_own_password() { | ||
| 795 | 859 | .await |
| 796 | 860 | .unwrap(); |
| 797 | 861 | assert!(!invitation.user.has_signed_in(), "no password yet"); |
| 798 | - assert!(invitation.expires_at > OffsetDateTime::now_utc() + SIGNIN_LINK_LIFETIME - Duration::minutes(1)); | |
| 862 | + assert!( | |
| 863 | + invitation.expires_at | |
| 864 | + > OffsetDateTime::now_utc() + SIGNIN_LINK_LIFETIME - Duration::minutes(1) | |
| 865 | + ); | |
| 799 | 866 | |
| 800 | 867 | // The admin cannot sign in as them in the meantime. |
| 801 | 868 | let as_them = accounts |
| @@ -804,7 +871,11 @@ async fn an_invited_member_chooses_their_own_password() { | ||
| 804 | 871 | assert!(matches!(as_them, Err(AccountError::Rejected))); |
| 805 | 872 | |
| 806 | 873 | let signed_in = accounts |
| 807 | - .redeem_signin_link(invitation.token.expose(), "sextant-and-chart", "198.51.100.7") | |
| 874 | + .redeem_signin_link( | |
| 875 | + invitation.token.expose(), | |
| 876 | + "sextant-and-chart", | |
| 877 | + "198.51.100.7", | |
| 878 | + ) | |
| 808 | 879 | .await |
| 809 | 880 | .unwrap(); |
| 810 | 881 | assert_eq!(signed_in.user.id, invitation.user.id); |
| @@ -825,7 +896,11 @@ async fn only_an_admin_may_invite() { | ||
| 825 | 896 | .await |
| 826 | 897 | .unwrap(); |
| 827 | 898 | let member = accounts |
| 828 | - .redeem_signin_link(invitation.token.expose(), "sextant-and-chart", "198.51.100.7") | |
| 899 | + .redeem_signin_link( | |
| 900 | + invitation.token.expose(), | |
| 901 | + "sextant-and-chart", | |
| 902 | + "198.51.100.7", | |
| 903 | + ) | |
| 829 | 904 | .await |
| 830 | 905 | .unwrap() |
| 831 | 906 | .user; |
| @@ -839,7 +914,9 @@ async fn only_an_admin_may_invite() { | ||
| 839 | 914 | let mut viewer = member.clone(); |
| 840 | 915 | viewer.role = Role::Viewer; |
| 841 | 916 | assert!(matches!( |
| 842 | - accounts.invite(&viewer, "linus@dizey.sh", "Linus", Role::Viewer).await, | |
| 917 | + accounts | |
| 918 | + .invite(&viewer, "linus@dizey.sh", "Linus", Role::Viewer) | |
| 919 | + .await, | |
| 843 | 920 | Err(AccountError::Forbidden) |
| 844 | 921 | )); |
| 845 | 922 | } |
| @@ -853,11 +930,19 @@ async fn a_link_works_once_and_a_wrong_one_never_does() { | ||
| 853 | 930 | .unwrap(); |
| 854 | 931 | |
| 855 | 932 | accounts |
| 856 | - .redeem_signin_link(invitation.token.expose(), "sextant-and-chart", "198.51.100.7") | |
| 933 | + .redeem_signin_link( | |
| 934 | + invitation.token.expose(), | |
| 935 | + "sextant-and-chart", | |
| 936 | + "198.51.100.7", | |
| 937 | + ) | |
| 857 | 938 | .await |
| 858 | 939 | .unwrap(); |
| 859 | 940 | let again = accounts |
| 860 | - .redeem_signin_link(invitation.token.expose(), "another-password", "198.51.100.7") | |
| 941 | + .redeem_signin_link( | |
| 942 | + invitation.token.expose(), | |
| 943 | + "another-password", | |
| 944 | + "198.51.100.7", | |
| 945 | + ) | |
| 861 | 946 | .await; |
| 862 | 947 | assert!(matches!(again, Err(AccountError::Rejected))); |
| 863 | 948 | |
| @@ -882,16 +967,28 @@ async fn a_rejected_password_does_not_burn_the_invitation() { | ||
| 882 | 967 | .unwrap(); |
| 883 | 968 | |
| 884 | 969 | assert!(matches!( |
| 885 | - accounts.redeem_signin_link(invitation.token.expose(), "grace!!", "198.51.100.7").await, | |
| 970 | + accounts | |
| 971 | + .redeem_signin_link(invitation.token.expose(), "grace!!", "198.51.100.7") | |
| 972 | + .await, | |
| 886 | 973 | Err(AccountError::Password(PasswordProblem::TooShort)) |
| 887 | 974 | )); |
| 888 | 975 | assert!(matches!( |
| 889 | - accounts.redeem_signin_link(invitation.token.expose(), "grace-hopper-1906", "198.51.100.7").await, | |
| 976 | + accounts | |
| 977 | + .redeem_signin_link( | |
| 978 | + invitation.token.expose(), | |
| 979 | + "grace-hopper-1906", | |
| 980 | + "198.51.100.7" | |
| 981 | + ) | |
| 982 | + .await, | |
| 890 | 983 | Err(AccountError::Password(PasswordProblem::LooksLikeYou)) |
| 891 | 984 | )); |
| 892 | 985 | // Still redeemable with a password that passes. |
| 893 | 986 | accounts |
| 894 | - .redeem_signin_link(invitation.token.expose(), "sextant-and-chart", "198.51.100.7") | |
| 987 | + .redeem_signin_link( | |
| 988 | + invitation.token.expose(), | |
| 989 | + "sextant-and-chart", | |
| 990 | + "198.51.100.7", | |
| 991 | + ) | |
| 895 | 992 | .await |
| 896 | 993 | .unwrap(); |
| 897 | 994 | } |
| @@ -916,7 +1013,9 @@ async fn an_expired_link_is_refused_and_resending_opens_the_same_account() { | ||
| 916 | 1013 | .await |
| 917 | 1014 | .unwrap(); |
| 918 | 1015 | assert!(matches!( |
| 919 | - accounts.redeem_signin_link(stale.expose(), "sextant-and-chart", "198.51.100.7").await, | |
| 1016 | + accounts | |
| 1017 | + .redeem_signin_link(stale.expose(), "sextant-and-chart", "198.51.100.7") | |
| 1018 | + .await, | |
| 920 | 1019 | Err(AccountError::Rejected) |
| 921 | 1020 | )); |
| 922 | 1021 | |
| @@ -998,12 +1097,16 @@ async fn sign_in_attempts_are_rate_limited_per_address() { | ||
| 998 | 1097 | } |
| 999 | 1098 | // The next attempt is refused before any Argon2 work happens. |
| 1000 | 1099 | assert!(matches!( |
| 1001 | - accounts.sign_in("ada@dizey.sh", "wrong", "203.0.113.9").await, | |
| 1100 | + accounts | |
| 1101 | + .sign_in("ada@dizey.sh", "wrong", "203.0.113.9") | |
| 1102 | + .await, | |
| 1002 | 1103 | Err(AccountError::RateLimited) |
| 1003 | 1104 | )); |
| 1004 | 1105 | // A different address from a fresh client is unaffected. |
| 1005 | 1106 | assert!(matches!( |
| 1006 | - accounts.sign_in("someone@dizey.sh", "wrong", "203.0.113.9").await, | |
| 1107 | + accounts | |
| 1108 | + .sign_in("someone@dizey.sh", "wrong", "203.0.113.9") | |
| 1109 | + .await, | |
| 1007 | 1110 | Err(AccountError::Rejected) |
| 1008 | 1111 | )); |
| 1009 | 1112 | } |
| @@ -1068,13 +1171,21 @@ async fn link_redemption_is_rate_limited_per_client() { | ||
| 1068 | 1171 | // Even the real link is refused now, from that client. |
| 1069 | 1172 | assert!(matches!( |
| 1070 | 1173 | accounts |
| 1071 | - .redeem_signin_link(invitation.token.expose(), "sextant-and-chart", "203.0.113.9") | |
| 1174 | + .redeem_signin_link( | |
| 1175 | + invitation.token.expose(), | |
| 1176 | + "sextant-and-chart", | |
| 1177 | + "203.0.113.9" | |
| 1178 | + ) | |
| 1072 | 1179 | .await, |
| 1073 | 1180 | Err(AccountError::RateLimited) |
| 1074 | 1181 | )); |
| 1075 | 1182 | // And the person on another machine is unaffected. |
| 1076 | 1183 | accounts |
| 1077 | - .redeem_signin_link(invitation.token.expose(), "sextant-and-chart", "198.51.100.7") | |
| 1184 | + .redeem_signin_link( | |
| 1185 | + invitation.token.expose(), | |
| 1186 | + "sextant-and-chart", | |
| 1187 | + "198.51.100.7", | |
| 1188 | + ) | |
| 1078 | 1189 | .await |
| 1079 | 1190 | .unwrap(); |
| 1080 | 1191 | } |
| @@ -1091,7 +1202,12 @@ async fn changing_a_password_is_rate_limited_per_client() { | ||
| 1091 | 1202 | } |
| 1092 | 1203 | assert!(matches!( |
| 1093 | 1204 | accounts |
| 1094 | - .change_password(&admin.id, "tide-tables-1892", "chronometer-1761", "203.0.113.9") | |
| 1205 | + .change_password( | |
| 1206 | + &admin.id, | |
| 1207 | + "tide-tables-1892", | |
| 1208 | + "chronometer-1761", | |
| 1209 | + "203.0.113.9" | |
| 1210 | + ) | |
| 1095 | 1211 | .await, |
| 1096 | 1212 | Err(AccountError::RateLimited) |
| 1097 | 1213 | )); |
| @@ -1111,7 +1227,9 @@ async fn a_successful_sign_in_clears_the_bucket() { | ||
| 1111 | 1227 | .unwrap(); |
| 1112 | 1228 | // Someone who mistypes and then gets it right is not left at the edge. |
| 1113 | 1229 | assert!(matches!( |
| 1114 | - accounts.sign_in("ada@dizey.sh", "wrong", "198.51.100.7").await, | |
| 1230 | + accounts | |
| 1231 | + .sign_in("ada@dizey.sh", "wrong", "198.51.100.7") | |
| 1232 | + .await, | |
| 1115 | 1233 | Err(AccountError::Rejected) |
| 1116 | 1234 | )); |
| 1117 | 1235 | } |
| @@ -1127,20 +1245,41 @@ async fn changing_a_password_signs_out_every_device() { | ||
| 1127 | 1245 | .sign_in("ada@dizey.sh", "tide-tables-1892", "198.51.100.8") |
| 1128 | 1246 | .await |
| 1129 | 1247 | .unwrap(); |
| 1130 | - assert!(accounts.authenticate(first.session_token.expose()).await.unwrap().is_some()); | |
| 1248 | + assert!( | |
| 1249 | + accounts | |
| 1250 | + .authenticate(first.session_token.expose()) | |
| 1251 | + .await | |
| 1252 | + .unwrap() | |
| 1253 | + .is_some() | |
| 1254 | + ); | |
| 1131 | 1255 | |
| 1132 | 1256 | let fresh = accounts |
| 1133 | - .change_password(&admin.id, "tide-tables-1892", "chronometer-1761", "198.51.100.7") | |
| 1257 | + .change_password( | |
| 1258 | + &admin.id, | |
| 1259 | + "tide-tables-1892", | |
| 1260 | + "chronometer-1761", | |
| 1261 | + "198.51.100.7", | |
| 1262 | + ) | |
| 1134 | 1263 | .await |
| 1135 | 1264 | .unwrap(); |
| 1136 | 1265 | |
| 1137 | 1266 | for old in [&first, &second] { |
| 1138 | 1267 | assert!( |
| 1139 | - accounts.authenticate(old.session_token.expose()).await.unwrap().is_none(), | |
| 1268 | + accounts | |
| 1269 | + .authenticate(old.session_token.expose()) | |
| 1270 | + .await | |
| 1271 | + .unwrap() | |
| 1272 | + .is_none(), | |
| 1140 | 1273 | "the pane promises this" |
| 1141 | 1274 | ); |
| 1142 | 1275 | } |
| 1143 | - assert!(accounts.authenticate(fresh.session_token.expose()).await.unwrap().is_some()); | |
| 1276 | + assert!( | |
| 1277 | + accounts | |
| 1278 | + .authenticate(fresh.session_token.expose()) | |
| 1279 | + .await | |
| 1280 | + .unwrap() | |
| 1281 | + .is_some() | |
| 1282 | + ); | |
| 1144 | 1283 | accounts |
| 1145 | 1284 | .sign_in("ada@dizey.sh", "chronometer-1761", "198.51.100.7") |
| 1146 | 1285 | .await |
| @@ -1151,11 +1290,15 @@ async fn changing_a_password_signs_out_every_device() { | ||
| 1151 | 1290 | async fn changing_a_password_needs_the_current_one_and_obeys_the_rules() { |
| 1152 | 1291 | let (_scratch, accounts, admin) = claimed().await; |
| 1153 | 1292 | assert!(matches!( |
| 1154 | - accounts.change_password(&admin.id, "not-it", "chronometer-1761", "198.51.100.7").await, | |
| 1293 | + accounts | |
| 1294 | + .change_password(&admin.id, "not-it", "chronometer-1761", "198.51.100.7") | |
| 1295 | + .await, | |
| 1155 | 1296 | Err(AccountError::Rejected) |
| 1156 | 1297 | )); |
| 1157 | 1298 | assert!(matches!( |
| 1158 | - accounts.change_password(&admin.id, "tide-tables-1892", "short", "198.51.100.7").await, | |
| 1299 | + accounts | |
| 1300 | + .change_password(&admin.id, "tide-tables-1892", "short", "198.51.100.7") | |
| 1301 | + .await, | |
| 1159 | 1302 | Err(AccountError::Password(PasswordProblem::TooShort)) |
| 1160 | 1303 | )); |
| 1161 | 1304 | // The old password still works after both refusals. |
| @@ -1177,9 +1320,24 @@ async fn signing_out_ends_that_browser_only() { | ||
| 1177 | 1320 | .await |
| 1178 | 1321 | .unwrap(); |
| 1179 | 1322 | |
| 1180 | - accounts.sign_out(laptop.session_token.expose()).await.unwrap(); | |
| 1181 | - assert!(accounts.authenticate(laptop.session_token.expose()).await.unwrap().is_none()); | |
| 1182 | - assert!(accounts.authenticate(phone.session_token.expose()).await.unwrap().is_some()); | |
| 1323 | + accounts | |
| 1324 | + .sign_out(laptop.session_token.expose()) | |
| 1325 | + .await | |
| 1326 | + .unwrap(); | |
| 1327 | + assert!( | |
| 1328 | + accounts | |
| 1329 | + .authenticate(laptop.session_token.expose()) | |
| 1330 | + .await | |
| 1331 | + .unwrap() | |
| 1332 | + .is_none() | |
| 1333 | + ); | |
| 1334 | + assert!( | |
| 1335 | + accounts | |
| 1336 | + .authenticate(phone.session_token.expose()) | |
| 1337 | + .await | |
| 1338 | + .unwrap() | |
| 1339 | + .is_some() | |
| 1340 | + ); | |
| 1183 | 1341 | // Signing out an unknown token is not an error. |
| 1184 | 1342 | accounts.sign_out(&"0".repeat(32)).await.unwrap(); |
| 1185 | 1343 | } |
| @@ -1192,11 +1350,15 @@ async fn an_address_can_only_be_invited_once() { | ||
| 1192 | 1350 | .await |
| 1193 | 1351 | .unwrap(); |
| 1194 | 1352 | assert!(matches!( |
| 1195 | - accounts.invite(&admin, "GRACE@dizey.sh", "Grace again", Role::Member).await, | |
| 1353 | + accounts | |
| 1354 | + .invite(&admin, "GRACE@dizey.sh", "Grace again", Role::Member) | |
| 1355 | + .await, | |
| 1196 | 1356 | Err(AccountError::AddressTaken) |
| 1197 | 1357 | )); |
| 1198 | 1358 | assert!(matches!( |
| 1199 | - accounts.invite(&admin, "ada@dizey.sh", "Ada again", Role::Member).await, | |
| 1359 | + accounts | |
| 1360 | + .invite(&admin, "ada@dizey.sh", "Ada again", Role::Member) | |
| 1361 | + .await, | |
| 1200 | 1362 | Err(AccountError::AddressTaken) |
| 1201 | 1363 | )); |
| 1202 | 1364 | } |
| @@ -1434,10 +1596,29 @@ async fn a_card_carries_its_assignees_comments_and_dependency_keys() { | ||
| 1434 | 1596 | async fn a_cleared_dependency_stops_showing_on_the_card() { |
| 1435 | 1597 | let (scratch, workspace, admin) = workspace_with_admin().await; |
| 1436 | 1598 | let store = &scratch.store; |
| 1437 | - let blocking = add_task(store, &workspace, "In Progress", "Invite flow", None, &admin).await; | |
| 1438 | - let blocked = add_task(store, &workspace, "Backlog", "Terms of service", None, &admin).await; | |
| 1599 | + let blocking = add_task( | |
| 1600 | + store, | |
| 1601 | + &workspace, | |
| 1602 | + "In Progress", | |
| 1603 | + "Invite flow", | |
| 1604 | + None, | |
| 1605 | + &admin, | |
| 1606 | + ) | |
| 1607 | + .await; | |
| 1608 | + let blocked = add_task( | |
| 1609 | + store, | |
| 1610 | + &workspace, | |
| 1611 | + "Backlog", | |
| 1612 | + "Terms of service", | |
| 1613 | + None, | |
| 1614 | + &admin, | |
| 1615 | + ) | |
| 1616 | + .await; | |
| 1439 | 1617 | let now = OffsetDateTime::now_utc(); |
| 1440 | - store.add_dependency(&blocked, &blocking, now).await.unwrap(); | |
| 1618 | + store | |
| 1619 | + .add_dependency(&blocked, &blocking, now) | |
| 1620 | + .await | |
| 1621 | + .unwrap(); | |
| 1441 | 1622 | |
| 1442 | 1623 | let board = board_of(store, &workspace).await; |
| 1443 | 1624 | assert!( |
| @@ -1646,7 +1827,10 @@ async fn a_task_detail_carries_both_directions_of_its_dependencies() { | ||
| 1646 | 1827 | assert_eq!(blocked_by, ["before"]); |
| 1647 | 1828 | assert_eq!(blocks, ["after"]); |
| 1648 | 1829 | assert!(detail.is_blocked()); |
| 1649 | - assert_eq!(detail.blocked_by[0].blocked_by_label(), "blocking this task"); | |
| 1830 | + assert_eq!( | |
| 1831 | + detail.blocked_by[0].blocked_by_label(), | |
| 1832 | + "blocking this task" | |
| 1833 | + ); | |
| 1650 | 1834 | assert_eq!(detail.blocks[0].blocks_label(), "waiting on this task"); |
| 1651 | 1835 | } |
| 1652 | 1836 | |
| @@ -1665,7 +1849,10 @@ async fn a_viewer_is_never_offered_as_an_assignee() { | ||
| 1665 | 1849 | .unwrap(); |
| 1666 | 1850 | let task = add_task(store, &workspace, "Backlog", "a task", None, &admin).await; |
| 1667 | 1851 | |
| 1668 | - let detail = load_detail(store, &workspace, &task).await.unwrap().unwrap(); | |
| 1852 | + let detail = load_detail(store, &workspace, &task) | |
| 1853 | + .await | |
| 1854 | + .unwrap() | |
| 1855 | + .unwrap(); | |
| 1669 | 1856 | assert!( |
| 1670 | 1857 | !detail.assignable.iter().any(|p| p.id == quiet.id), |
| 1671 | 1858 | "a viewer cannot be given work, so the picker never lists one" |
| @@ -1749,19 +1936,31 @@ async fn deleting_a_task_frees_what_was_waiting_on_it() { | ||
| 1749 | 1936 | .add_dependency(&still_stuck, &blocking, now) |
| 1750 | 1937 | .await |
| 1751 | 1938 | .unwrap(); |
| 1752 | - store.add_dependency(&still_stuck, &other, now).await.unwrap(); | |
| 1939 | + store | |
| 1940 | + .add_dependency(&still_stuck, &other, now) | |
| 1941 | + .await | |
| 1942 | + .unwrap(); | |
| 1753 | 1943 | |
| 1754 | 1944 | let unblocked = store.delete_task(&blocking, &admin, now).await.unwrap(); |
| 1755 | - assert_eq!(unblocked, vec![freed.clone()], "only the one with nothing else in front of it"); | |
| 1945 | + assert_eq!( | |
| 1946 | + unblocked, | |
| 1947 | + vec![freed.clone()], | |
| 1948 | + "only the one with nothing else in front of it" | |
| 1949 | + ); | |
| 1756 | 1950 | |
| 1757 | 1951 | // The deleted task is gone from the board and from the edges it stood in. |
| 1758 | 1952 | let board = board_of(store, &workspace).await; |
| 1759 | - assert!(!board | |
| 1760 | - .columns | |
| 1761 | - .iter() | |
| 1762 | - .flat_map(|column| column.cards.iter()) | |
| 1763 | - .any(|card| card.id == blocking)); | |
| 1764 | - let freed_detail = load_detail(store, &workspace, &freed).await.unwrap().unwrap(); | |
| 1953 | + assert!( | |
| 1954 | + !board | |
| 1955 | + .columns | |
| 1956 | + .iter() | |
| 1957 | + .flat_map(|column| column.cards.iter()) | |
| 1958 | + .any(|card| card.id == blocking) | |
| 1959 | + ); | |
| 1960 | + let freed_detail = load_detail(store, &workspace, &freed) | |
| 1961 | + .await | |
| 1962 | + .unwrap() | |
| 1963 | + .unwrap(); | |
| 1765 | 1964 | assert!(freed_detail.blocked_by.is_empty()); |
| 1766 | 1965 | assert!(!freed_detail.is_blocked()); |
| 1767 | 1966 | |
| @@ -1772,18 +1971,26 @@ async fn deleting_a_task_frees_what_was_waiting_on_it() { | ||
| 1772 | 1971 | .iter() |
| 1773 | 1972 | .find(|entry| entry.kind == ActivityKind::Unblocked) |
| 1774 | 1973 | .expect("the freeing is on the record"); |
| 1775 | - assert!(unblocked_line.actor.is_none(), "the system did this, not a person"); | |
| 1974 | + assert!( | |
| 1975 | + unblocked_line.actor.is_none(), | |
| 1976 | + "the system did this, not a person" | |
| 1977 | + ); | |
| 1776 | 1978 | assert!(unblocked_line.sentence().starts_with("unblocked this task")); |
| 1777 | 1979 | |
| 1778 | 1980 | let stuck_detail = load_detail(store, &workspace, &still_stuck) |
| 1779 | 1981 | .await |
| 1780 | 1982 | .unwrap() |
| 1781 | 1983 | .unwrap(); |
| 1782 | - assert!(stuck_detail.is_blocked(), "something else is still in front of it"); | |
| 1783 | - assert!(!stuck_detail | |
| 1784 | - .activity | |
| 1785 | - .iter() | |
| 1786 | - .any(|entry| entry.kind == ActivityKind::Unblocked)); | |
| 1984 | + assert!( | |
| 1985 | + stuck_detail.is_blocked(), | |
| 1986 | + "something else is still in front of it" | |
| 1987 | + ); | |
| 1988 | + assert!( | |
| 1989 | + !stuck_detail | |
| 1990 | + .activity | |
| 1991 | + .iter() | |
| 1992 | + .any(|entry| entry.kind == ActivityKind::Unblocked) | |
| 1993 | + ); | |
| 1787 | 1994 | |
| 1788 | 1995 | // A second delete finds nothing to delete. |
| 1789 | 1996 | assert!(matches!( |
| @@ -1809,9 +2016,16 @@ async fn saving_a_task_records_only_what_changed() { | ||
| 1809 | 2016 | ) |
| 1810 | 2017 | .await |
| 1811 | 2018 | .unwrap(); |
| 1812 | - let detail = load_detail(store, &workspace, &task).await.unwrap().unwrap(); | |
| 2019 | + let detail = load_detail(store, &workspace, &task) | |
| 2020 | + .await | |
| 2021 | + .unwrap() | |
| 2022 | + .unwrap(); | |
| 1813 | 2023 | let kinds: Vec<&ActivityKind> = detail.activity.iter().map(|e| &e.kind).collect(); |
| 1814 | - assert_eq!(kinds, [&ActivityKind::Created], "a save that changed nothing says nothing"); | |
| 2024 | + assert_eq!( | |
| 2025 | + kinds, | |
| 2026 | + [&ActivityKind::Created], | |
| 2027 | + "a save that changed nothing says nothing" | |
| 2028 | + ); | |
| 1815 | 2029 | |
| 1816 | 2030 | store |
| 1817 | 2031 | .save_task( |
| @@ -1824,7 +2038,10 @@ async fn saving_a_task_records_only_what_changed() { | ||
| 1824 | 2038 | ) |
| 1825 | 2039 | .await |
| 1826 | 2040 | .unwrap(); |
| 1827 | - let detail = load_detail(store, &workspace, &task).await.unwrap().unwrap(); | |
| 2041 | + let detail = load_detail(store, &workspace, &task) | |
| 2042 | + .await | |
| 2043 | + .unwrap() | |
| 2044 | + .unwrap(); | |
| 1828 | 2045 | assert_eq!(detail.title, "second title"); |
| 1829 | 2046 | assert_eq!(detail.description, "some prose"); |
| 1830 | 2047 | assert_eq!(detail.deadline_input(), "2026-09-12"); |
| @@ -1871,10 +2088,17 @@ async fn a_task_detail_costs_seven_queries_whatever_it_carries() { | ||
| 1871 | 2088 | .await |
| 1872 | 2089 | .unwrap(); |
| 1873 | 2090 | store |
| 1874 | - .record_activity(&heavy, Some(&person.id), &ActivityKind::Moved, "to Review", now) | |
| 2091 | + .record_activity( | |
| 2092 | + &heavy, | |
| 2093 | + Some(&person.id), | |
| 2094 | + &ActivityKind::Moved, | |
| 2095 | + "to Review", | |
| 2096 | + now, | |
| 2097 | + ) | |
| 1875 | 2098 | .await |
| 1876 | 2099 | .unwrap(); |
| 1877 | - let neighbour = add_task(store, &workspace, "Backlog", &format!("n{n}"), None, &admin).await; | |
| 2100 | + let neighbour = | |
| 2101 | + add_task(store, &workspace, "Backlog", &format!("n{n}"), None, &admin).await; | |
| 1878 | 2102 | store.add_dependency(&neighbour, &heavy, now).await.unwrap(); |
| 1879 | 2103 | } |
| 1880 | 2104 |
crates/dizey-web/src/main.rsmodified+2 -2
| @@ -29,8 +29,8 @@ async fn main() { | ||
| 29 | 29 | listener, |
| 30 | 30 | app.into_make_service_with_connect_info::<std::net::SocketAddr>(), |
| 31 | 31 | ) |
| 32 | - .await | |
| 33 | - .expect("server error"); | |
| 32 | + .await | |
| 33 | + .expect("server error"); | |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | #[cfg(not(feature = "ssr"))] |