From 07c44187a095174e05cebf4db0e80881ae97afd2 Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Tue, 14 Jan 2025 22:42:51 +0100 Subject: [PATCH] more tests --- crates/core/tests/integration/vfs.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/crates/core/tests/integration/vfs.rs b/crates/core/tests/integration/vfs.rs index 319db6f0..502f425f 100644 --- a/crates/core/tests/integration/vfs.rs +++ b/crates/core/tests/integration/vfs.rs @@ -6,7 +6,10 @@ use insta::Settings; use pretty_assertions::assert_eq; use rstest::rstest; -use rustic_core::{repofile::SnapshotFile, vfs::Vfs, BackupOptions}; +use rustic_core::{ + vfs::{IdenticalSnapshot, Latest, Vfs}, + BackupOptions, SnapshotOptions, +}; use typed_path::UnixPath; use super::{ @@ -26,7 +29,8 @@ fn test_vfs( // we use as_path to not depend on the actual tempdir let opts = BackupOptions::default().as_path(PathBuf::from_str("test")?); // backup test-data - let snapshot = repo.backup(&opts, paths, SnapshotFile::default())?; + let snap_opts = SnapshotOptions::default().label("label".to_string()); + let snapshot = repo.backup(&opts, paths, snap_opts.to_snapshot()?)?; // re-read index let repo = repo.to_indexed()?; @@ -54,5 +58,17 @@ fn test_vfs( let node = vfs.node_from_path(&repo, UnixPath::new("test/0/tests/empty-file"))?; let file = repo.open_file(&node)?; assert_eq!(Bytes::new(), repo.read_file_at(&file, 0, 0)?); // empty files + + // create Vfs from snapshots + let vfs = Vfs::from_snapshots( + vec![snapshot], + "{label}/{time}", + "%Y", + Latest::AsDir, + IdenticalSnapshot::AsLink, + )?; + let entries_from_snapshots = + vfs.dir_entries_from_path(&repo, UnixPath::new("label/latest/test/0/tests"))?; + assert_eq!(entries_from_snapshots, entries); Ok(()) }