use std::{env, fs};
use assert_cmd::cargo;
use rstest::rstest;
use serial_test::file_serial;
use testresult::TestResult;
mod utils;
#[rstest]
#[case(false)]
#[case(true)]
#[file_serial(unzip)]
fn unzip(#[case] delete: bool) -> TestResult {
let temp_dir = tempfile::tempdir()?;
let input_path = utils::copy_to_temp_dir("pandoc-epub.epub", temp_dir.path())?;
let mut cmd = cargo::cargo_bin_cmd!();
if delete {
cmd.args([
"unzip",
"--delete",
input_path.display().to_string().as_str(),
]);
cmd.assert().success();
assert!(!input_path.try_exists()?);
} else {
cmd.args(["unzip", input_path.display().to_string().as_str()]);
cmd.assert().success();
assert!(input_path.is_file());
}
let epub_dir_path = env::current_dir()?.join("pandoc-epub");
novel_cli::utils::ensure_epub_dir(&epub_dir_path)?;
fs::remove_dir_all(epub_dir_path)?;
Ok(())
}