22 lines
785 B
Rust
22 lines
785 B
Rust
use color_eyre::eyre::{ensure, Context, Result};
|
|
use stranger_site_gen::site::Site;
|
|
|
|
/// Test that serializing out a fresh site and reading it back in gives back the same [`Site`]
|
|
#[test]
|
|
fn write_read_default() -> Result<()> {
|
|
// Get a temporary directory
|
|
let tempdir = tempfile::tempdir().context("Failed to get temporary directory")?;
|
|
let tempdir_path = tempdir.path();
|
|
// Generate our site
|
|
let mut site_input = Site::default();
|
|
// Write it out
|
|
site_input
|
|
.write(tempdir_path)
|
|
.context("Failed to write out site")?;
|
|
// Read it back in
|
|
let site_output = Site::read(tempdir_path).context("Failed to read in site")?;
|
|
// Make sure the results are equal
|
|
ensure!(site_input == site_output, "Sites were not equal");
|
|
Ok(())
|
|
}
|