| 1 | use super::*; |
| 2 | |
| 3 | #[test] |
| 4 | fn conflict_adapter_preserves_sizes_names_ids_and_choices() { |
| 5 | let required = || wire::Message::ConflictRequired { |
| 6 | challenge_id: 53, |
| 7 | entry_id: 7, |
| 8 | relative_name: "사진/기록.txt".into(), |
| 9 | incoming_size: u64::MAX, |
| 10 | existing_size: 1 << 34, |
| 11 | }; |
| 12 | match event_to_ui(required(), Some(wire::ActionKind::Extract)).unwrap() { |
| 13 | ui::Event::ConflictRequired(c) => { |
| 14 | assert_eq!(c.challenge_id, 53); |
| 15 | assert_eq!(c.entry_id, 7); |
| 16 | assert_eq!(c.relative_name, "사진/기록.txt"); |
| 17 | assert_eq!(c.incoming_size, u64::MAX); |
| 18 | assert_eq!(c.existing_size, 1 << 34); |
| 19 | } |
| 20 | _ => panic!("충돌 요청 변환 누락"), |
| 21 | } |
| 22 | for expected in [ |
| 23 | None, |
| 24 | Some(wire::ActionKind::List), |
| 25 | Some(wire::ActionKind::CreateZip), |
| 26 | ] { |
| 27 | assert!(event_to_ui(required(), expected).is_err()); |
| 28 | } |
| 29 | for choice in [ |
| 30 | ui::ConflictChoice::Overwrite, |
| 31 | ui::ConflictChoice::Skip, |
| 32 | ui::ConflictChoice::Rename, |
| 33 | ] { |
| 34 | match event_to_ui( |
| 35 | wire::Message::ConflictResolved { |
| 36 | entry_id: 7, |
| 37 | relative_name: "사진/기록 (1).txt".into(), |
| 38 | choice: conflict_to_wire(choice), |
| 39 | }, |
| 40 | Some(wire::ActionKind::Extract), |
| 41 | ) |
| 42 | .unwrap() |
| 43 | { |
| 44 | ui::Event::ConflictResolved(r) => { |
| 45 | assert_eq!(r.choice, choice); |
| 46 | assert_eq!(r.entry_id, 7); |
| 47 | assert_eq!(r.relative_name, "사진/기록 (1).txt"); |
| 48 | } |
| 49 | _ => panic!("충돌 결과 변환 누락"), |
| 50 | } |
| 51 | } |
| 52 | } |