use std::env;
use std::fs;
use anyhow::Result;
use crate::ingest::store;
#[test]
fn write_an_image() -> Result<()> {
let d = tempfile::Builder::new().prefix("quad-image").tempdir()?;
env::set_current_dir(d.path())?;
let mut e = d.path().to_path_buf();
e.push("e");
fs::create_dir(&e)?;
let mut input = d.path().to_path_buf();
input.push("test.png");
store(include_bytes!("test.png"))?;
store(include_bytes!("../tests/parrot.gif"))?;
let mut now_extensions = fs::read_dir(&e)?
.map(|e| {
e.unwrap()
.path()
.extension()
.unwrap()
.to_string_lossy()
.to_string()
})
.collect::<Vec<String>>();
now_extensions.sort();
assert_eq!(
&["gif", "png"],
now_extensions.as_slice(),
"created one of each"
);
Ok(())
}