Apply cargo fmt to settings and attendance tests
Browse files at this commit9d57d6aa43500074b8ceb6c9079516f2fbfa5853Parent: caa814c- style
- apply cargo fmt to settings and attendance tests
2 changed files +13 -10
- src/domain/attendance.rs +3 -1
- src/domain/settings.rs +10 -9
src/domain/attendance.rsmodified+3 -1
| @@ -159,7 +159,9 @@ mod tests { | |||
| 159 | .to_vec(); | 159 | .to_vec(); |
| 160 | for status in ["present", "absent", "late", "excused"] { | 160 | for status in ["present", "absent", "late", "excused"] { |
| 161 | assert_eq!( | 161 | assert_eq!( |
| 162 | - AttendanceStatus::try_new(status, &allowed).unwrap().as_str(), | 162 | + AttendanceStatus::try_new(status, &allowed) |
| 163 | + .unwrap() | ||
| 164 | + .as_str(), | ||
| 163 | status | 165 | status |
| 164 | ); | 166 | ); |
| 165 | } | 167 | } |
src/domain/settings.rsmodified+10 -9
| @@ -176,10 +176,7 @@ impl Settings { | |||
| 176 | 176 | ||
| 177 | /// Shared rules for the editable string lists: 1–20 trimmed, non-empty, | 177 | /// Shared rules for the editable string lists: 1–20 trimmed, non-empty, |
| 178 | /// ≤50-char entries with no case-insensitive duplicates. | 178 | /// ≤50-char entries with no case-insensitive duplicates. |
| 179 | -fn validate_list( | 179 | +fn validate_list(field: &'static str, values: Vec<String>) -> Result<Vec<String>, ValidationError> { |
| 180 | - field: &'static str, | ||
| 181 | - values: Vec<String>, | ||
| 182 | -) -> Result<Vec<String>, ValidationError> { | ||
| 183 | if values.is_empty() { | 180 | if values.is_empty() { |
| 184 | return Err(ValidationError::Empty(field)); | 181 | return Err(ValidationError::Empty(field)); |
| 185 | } | 182 | } |
| @@ -315,11 +312,15 @@ mod tests { | |||
| 315 | // Save a custom policy and read it back — bands (nested objects under | 312 | // Save a custom policy and read it back — bands (nested objects under |
| 316 | // a FLEXIBLE field) must survive the trip. | 313 | // a FLEXIBLE field) must survive the trip. |
| 317 | let statuses = Settings::defaults().get_attendance_statuses().to_vec(); | 314 | let statuses = Settings::defaults().get_attendance_statuses().to_vec(); |
| 318 | - Settings::try_new(kinds(&["lab"]), statuses.clone(), bands(&[(0, "F"), (50, "P")])) | 315 | + Settings::try_new( |
| 319 | - .unwrap() | 316 | + kinds(&["lab"]), |
| 320 | - .save(&db) | 317 | + statuses.clone(), |
| 321 | - .await | 318 | + bands(&[(0, "F"), (50, "P")]), |
| 322 | - .unwrap(); | 319 | + ) |
| 320 | + .unwrap() | ||
| 321 | + .save(&db) | ||
| 322 | + .await | ||
| 323 | + .unwrap(); | ||
| 323 | let loaded = Settings::load(&db).await.unwrap(); | 324 | let loaded = Settings::load(&db).await.unwrap(); |
| 324 | assert_eq!(loaded.get_exam_kinds(), ["lab"]); | 325 | assert_eq!(loaded.get_exam_kinds(), ["lab"]); |
| 325 | assert_eq!(loaded.get_grade_bands().len(), 2); | 326 | assert_eq!(loaded.get_grade_bands().len(), 2); |