mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-22 00:51:38 +03:00
bbf4d7c817
Created on the fly while perusing the test-suite. * avoid unnecessary `test_` prefix * move more (and previously missed) test modules to integration level * make `dedup` crate-private to have a reason to keep the tests where they are, same with similar functions
48 lines
1.4 KiB
Rust
48 lines
1.4 KiB
Rust
use gitbutler_app::zip::Zipper;
|
|
use walkdir::WalkDir;
|
|
|
|
use std::fs::File;
|
|
use std::io::Write;
|
|
use tempfile::tempdir;
|
|
|
|
#[test]
|
|
fn zip_dir() {
|
|
let tmp_dir = tempdir().unwrap();
|
|
let tmp_dir_path = tmp_dir.path();
|
|
let file_path = tmp_dir_path.join("test.txt");
|
|
let mut file = File::create(file_path).unwrap();
|
|
file.write_all(b"test").unwrap();
|
|
|
|
let zipper_cache = tempdir().unwrap();
|
|
let zipper = Zipper::new(zipper_cache.path());
|
|
let zip_file_path = zipper.zip(tmp_dir).unwrap();
|
|
assert!(zip_file_path.exists());
|
|
}
|
|
|
|
#[test]
|
|
fn zip_file() {
|
|
let tmp_dir = tempdir().unwrap();
|
|
let tmp_dir_path = tmp_dir.path();
|
|
let file_path = tmp_dir_path.join("test.txt");
|
|
let mut file = File::create(&file_path).unwrap();
|
|
file.write_all(b"test").unwrap();
|
|
|
|
let zipper_cache = tempdir().unwrap();
|
|
let zipper = Zipper::new(zipper_cache.path());
|
|
zipper.zip(file_path).unwrap_err();
|
|
}
|
|
|
|
#[test]
|
|
fn zip_once() {
|
|
let tmp_dir = tempdir().unwrap();
|
|
let tmp_dir_path = tmp_dir.path();
|
|
let file_path = tmp_dir_path.join("test.txt");
|
|
let mut file = File::create(file_path).unwrap();
|
|
file.write_all(b"test").unwrap();
|
|
|
|
let zipper_cache = tempdir().unwrap();
|
|
let zipper = Zipper::new(zipper_cache.path());
|
|
assert_eq!(zipper.zip(&tmp_dir).unwrap(), zipper.zip(&tmp_dir).unwrap());
|
|
assert_eq!(WalkDir::new(tmp_dir).into_iter().count(), 1);
|
|
}
|