Skip to content

Commit a935fb8

Browse files
committed
tests: replace writing to test file with in-memory cursor, closes #65
and delete empty file created after running the test
1 parent ba801bc commit a935fb8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22
//!
33
//! ```
44
//! # use std::error::Error;
5+
//! # use std::fs;
6+
//! # use std::io::{Cursor, Write as _};
57
//! # use wacksy::WACZ;
68
//! # fn main() -> Result<(), Box<dyn Error>> {
79
//! let warc_file_path = std::path::Path::new("tests/example.warc.gz"); // set path to your ᴡᴀʀᴄ file
810
//! let wacz_object = WACZ::from_file(warc_file_path)?; // index the ᴡᴀʀᴄ and create a ᴡᴀᴄᴢ object
911
//! let zipped_wacz: Vec<u8> = wacz_object.as_zip_archive()?; // zip up the ᴡᴀᴄᴢ
10-
//! std::fs::write("tests/output.wacz", zipped_wacz)?; // write out to file
12+
//! let mut wacz_file = fs::File::create("tests/example.wacz")?;
13+
//! # let mut wacz_file = Cursor::new(vec![0; 2048]);
14+
//! wacz_file.write_all(&zipped_wacz)?; // write out to file
15+
//! # fs::remove_file("tests/example.wacz")?;
1116
//! # Ok(())
1217
//! # }
13-
//! ```
18+
//!
1419
#![doc(
1520
html_logo_url = "https://www.ox.ac.uk/sites/default/themes/custom/oxweb/images/oxweb-logo.gif",
1621
html_favicon_url = "https://www.bodleian.ox.ac.uk/sites/default/files/styles/favicon-32x32/public/bodreader/site-favicon/bod-favicon.png"
@@ -46,7 +51,7 @@ impl WACZ {
4651
/// # Errors
4752
///
4853
/// Returns a [`WaczError`], which can be caused by a problem in either the
49-
/// [indexer](IndexingError) or the [datapackage](DataPackageError). As the
54+
/// indexer (structured errors to-do) or the [datapackage](DataPackageError). As the
5055
/// datapackage depends on the index being complete, any problem with the
5156
/// indexer will return early without continuing.
5257
pub fn from_file(warc_file_path: &Path) -> Result<Self, WaczError> {

0 commit comments

Comments
 (0)