| 1 | #[test] |
| 2 | fn compressed_tar_opens_with_native_dialog_and_extracts_to_compound_stem() { |
| 3 | use zipelo_ui_memory_app::archive_dialog::Purpose; |
| 4 | for (kind, name) in [("bz2", "여행 자료.TaR.Bz2"), ("xz", "여행 자료.tAr.XZ")] { |
| 5 | let scratch = Scratch::new(); |
| 6 | let generated = std::process::Command::new("python3") |
| 7 | .arg( |
| 8 | Path::new(env!("CARGO_MANIFEST_DIR")) |
| 9 | .join("../../tests/rust-archive-worker/compressed_tar_cases.py"), |
| 10 | ) |
| 11 | .arg(&scratch.0) |
| 12 | .arg(kind) |
| 13 | .arg("normal") |
| 14 | .output() |
| 15 | .unwrap(); |
| 16 | assert!( |
| 17 | generated.status.success(), |
| 18 | "{}", |
| 19 | String::from_utf8_lossy(&generated.stderr) |
| 20 | ); |
| 21 | let archive = scratch.path(name); |
| 22 | fs::rename(scratch.path("input"), &archive).unwrap(); |
| 23 | let original = fs::read(&archive).unwrap(); |
| 24 | let (factory, observed) = observed_factory(); |
| 25 | let mut screen = Screen::new(factory); |
| 26 | screen |
| 27 | .dialogs |
| 28 | .0 |
| 29 | .borrow_mut() |
| 30 | .answers |
| 31 | .push_back(Some(vec![archive.clone()])); |
| 32 | screen.click("열기"); |
| 33 | screen.settle(); |
| 34 | assert_eq!(screen.dialogs.0.borrow().requests[0].purpose, Purpose::Open); |
| 35 | assert_eq!( |
| 36 | screen.app.model.list_id.as_ref().unwrap().format, |
| 37 | Format::Tar |
| 38 | ); |
| 39 | assert!( |
| 40 | screen |
| 41 | .app |
| 42 | .model |
| 43 | .entries |
| 44 | .iter() |
| 45 | .any(|e| e.name == "한글.txt") |
| 46 | ); |
| 47 | assert!(screen.app.begin_extract()); |
| 48 | screen.settle(); |
| 49 | let output = scratch.path("여행 자료"); |
| 50 | assert_eq!( |
| 51 | fs::read(output.join("folder/payload.bin")).unwrap(), |
| 52 | fs::read(scratch.path("expected")).unwrap() |
| 53 | ); |
| 54 | assert_eq!(fs::read(output.join("한글.txt")).unwrap(), b"end"); |
| 55 | assert!(output.join("empty").is_dir()); |
| 56 | assert_eq!(fs::read(&archive).unwrap(), original); |
| 57 | assert!( |
| 58 | matches!(observed.borrow().starts.last(), Some(Start::Extract { |
| 59 | destination, gzip_output_name: None, .. |
| 60 | }) if destination == &output) |
| 61 | ); |
| 62 | let labels = screen |
| 63 | .render(vec![]) |
| 64 | .into_iter() |
| 65 | .map(|(s, _)| s) |
| 66 | .collect::<Vec<_>>() |
| 67 | .join("\n"); |
| 68 | assert!(labels.contains("압축을 풀었습니다"), "{labels}"); |
| 69 | assert_reaped(&observed); |
| 70 | } |
| 71 | } |