All checks were successful
Checking Renovate configuration / validate (pull_request) Successful in 2m6s
Build and test / Tests (pull_request) Successful in 4m52s
Checking yaml / Run yamllint (pull_request) Successful in 6s
Build and test / Clippy (pull_request) Successful in 4m56s
Build and test / Build AMD64 (pull_request) Successful in 6m11s
Build and test / Generate Documentation (pull_request) Successful in 4m49s
52 lines
1.5 KiB
Rust
52 lines
1.5 KiB
Rust
use std::path::PathBuf;
|
|
|
|
use cbz2pdf::formats::FormatId;
|
|
use cbz2pdf::job::Job;
|
|
|
|
#[test]
|
|
fn detect_from_path_recognizes_extensions() {
|
|
let cbz = PathBuf::from("/tmp/book.cbz");
|
|
let pdf = PathBuf::from("/tmp/book.pdf");
|
|
let cbr = PathBuf::from("/tmp/book.cbr");
|
|
assert_eq!(FormatId::detect_from_path(&cbz), Some(FormatId::Cbz));
|
|
assert_eq!(FormatId::detect_from_path(&pdf), Some(FormatId::Pdf));
|
|
assert_eq!(FormatId::detect_from_path(&cbr), Some(FormatId::Cbr));
|
|
assert_eq!(
|
|
FormatId::detect_from_path(&PathBuf::from("/tmp/book.txt")),
|
|
None
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn job_new_sets_output_extension() {
|
|
let input = PathBuf::from("/tmp/book.cbz");
|
|
let outdir = PathBuf::from("/tmp");
|
|
let job = Job::new(input.clone(), outdir.clone(), FormatId::Cbz, FormatId::Pdf);
|
|
assert!(job.output_path.ends_with("book.pdf"));
|
|
|
|
let job2 = Job::new(
|
|
PathBuf::from("/tmp/book.pdf"),
|
|
outdir.clone(),
|
|
FormatId::Pdf,
|
|
FormatId::Cbz,
|
|
);
|
|
assert!(job2.output_path.ends_with("book.cbz"));
|
|
|
|
let job3 = Job::new(
|
|
PathBuf::from("/tmp/book.cbz"),
|
|
outdir,
|
|
FormatId::Cbz,
|
|
FormatId::Cbr,
|
|
);
|
|
assert!(job3.output_path.ends_with("book.cbr"));
|
|
}
|
|
|
|
#[test]
|
|
fn format_capabilities_consistent() {
|
|
assert!(FormatId::Cbz.can_read());
|
|
assert!(FormatId::Cbz.can_write());
|
|
assert!(FormatId::Pdf.can_write());
|
|
assert!(FormatId::Pdf.can_read());
|
|
assert!(FormatId::Cbr.can_read());
|
|
assert!(!FormatId::Cbr.can_write());
|
|
}
|