Skip to content

Commit

Permalink
cleanup, add new snapshots
Browse files Browse the repository at this point in the history
Signed-off-by: simonsan <[email protected]>
  • Loading branch information
simonsan committed Mar 12, 2024
1 parent e31c9af commit 1d359cf
Show file tree
Hide file tree
Showing 80 changed files with 153 additions and 366 deletions.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/0
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/1
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/10
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/11
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/12
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/13
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/14
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/15
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/16
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/17
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/18
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/19
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/2
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/20
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/21
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/22
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/23
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/24
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/25
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/26
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/27
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/28
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/29
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/3
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/30
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/31
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/32
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/33
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/34
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/35
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/36
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/37
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/38
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/39
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/4
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/40
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/41
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/42
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/43
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/44
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/45
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/46
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/47
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/48
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/49
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/5
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/50
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/51
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/52
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/53
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/54
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/55
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/56
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/57
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/58
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/59
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/6
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/60
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/61
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/62
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/63
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/64
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/65
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/66
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/67
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/68
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/7
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/8
Binary file not shown.
Binary file removed crates/core/tests/fixtures/backup-data/0/9/9
Binary file not shown.
Empty file.
1 change: 0 additions & 1 deletion crates/core/tests/fixtures/backup-data/tests/testfile

This file was deleted.

This file was deleted.

This file was deleted.

119 changes: 18 additions & 101 deletions crates/core/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ fn tar_gz_testdata() -> Result<TestSource> {
Ok(TestSource::new(dir))
}

// TODO!: Remove?
#[fixture]
fn dir_testdata() -> PathBuf {
Path::new("tests/fixtures/backup-data/")
.canonicalize()
.expect("fixture path")
}

// Parts of the snapshot summary we want to test against references
struct TestSummary<'a>(&'a SnapshotFile);

Expand Down Expand Up @@ -100,81 +92,6 @@ impl<'a> std::fmt::Debug for TestSummary<'a> {
}
}

#[rstest]
fn test_backup_with_dir_passes(dir_testdata: PathBuf, set_up_repo: Result<RepoOpen>) -> Result<()> {
// uncomment for logging output
// SimpleLogger::init(log::LevelFilter::Debug, Config::default())?;

// Fixtures
let (source, repo) = (dir_testdata, set_up_repo?.to_indexed_ids()?);

let paths = PathList::from_iter(Some(source));

// we use as_path to not depend on the actual tempdir
let opts = BackupOptions::default().as_path(PathBuf::from_str("test")?);

// first backup
let first_snapshot = repo.backup(&opts, &paths, SnapshotFile::default())?;
#[cfg(windows)]
assert_debug_snapshot!(
"backup-dir-summary-first-windows",
TestSummary(&first_snapshot)
);

#[cfg(not(windows))]
assert_debug_snapshot!("backup-dir-summary-first-nix", TestSummary(&first_snapshot));

assert_eq!(first_snapshot.parent, None);

// tree of first backup
// re-read index
let repo = repo.to_indexed_ids()?;
let tree = repo.node_from_path(first_snapshot.tree, Path::new("test/tests"))?;
let tree = repo.get_tree(&tree.subtree.expect("Sub tree"))?;

#[cfg(windows)]
assert_debug_snapshot!("backup-dir-tree-windows", tree);

#[cfg(not(windows))]
assert_debug_snapshot!("backup-dir-tree-nix", tree);

// get all snapshots and check them
let all_snapshots = repo.get_all_snapshots()?;
assert_eq!(vec![first_snapshot.clone()], all_snapshots);
// save list of pack files
let packs1: Vec<_> = repo.list(rustic_core::FileType::Pack)?.collect();

// re-read index
let repo = repo.to_indexed_ids()?;
// second backup
let second_snapshot = repo.backup(&opts, &paths, SnapshotFile::default())?;

#[cfg(windows)]
assert_debug_snapshot!(
"backup-dir-summary-second-windows",
TestSummary(&second_snapshot)
);

#[cfg(not(windows))]
assert_debug_snapshot!(
"backup-dir-summary-second-nix",
TestSummary(&second_snapshot)
);

assert_eq!(second_snapshot.parent, Some(first_snapshot.id));
assert_eq!(first_snapshot.tree, second_snapshot.tree);

// get all snapshots and check them
let mut all_snapshots = repo.get_all_snapshots()?;
all_snapshots.sort_unstable();
assert_eq!(vec![first_snapshot, second_snapshot], all_snapshots);

// pack files should be unchanged
let packs2: Vec<_> = repo.list(rustic_core::FileType::Pack)?.collect();
assert_eq!(packs1, packs2);
Ok(())
}

#[rstest]
fn test_backup_with_tar_gz_passes(
tar_gz_testdata: Result<TestSource>,
Expand Down Expand Up @@ -205,17 +122,17 @@ fn test_backup_with_tar_gz_passes(

assert_eq!(first_snapshot.parent, None);

// // tree of first backup
// // re-read index
// let repo = repo.to_indexed_ids()?;
// let tree = repo.node_from_path(first_snapshot.tree, Path::new("test/tests"))?;
// let tree = repo.get_tree(&tree.subtree.expect("Sub tree"))?;
// tree of first backup
// re-read index
let repo = repo.to_indexed_ids()?;
let tree = repo.node_from_path(first_snapshot.tree, Path::new("test/0/tests"))?;
let tree = repo.get_tree(&tree.subtree.expect("Sub tree"))?;

// #[cfg(windows)]
// assert_debug_snapshot!("backup-tar-tree-windows", tree);
#[cfg(windows)]
assert_debug_snapshot!("backup-tar-tree-windows", tree);

// #[cfg(not(windows))]
// assert_debug_snapshot!("backup-tar-tree-nix", tree);
#[cfg(not(windows))]
assert_debug_snapshot!("backup-tar-tree-nix", tree);

// get all snapshots and check them
let all_snapshots = repo.get_all_snapshots()?;
Expand Down Expand Up @@ -292,17 +209,17 @@ fn test_backup_dry_run_with_tar_gz_passes(
assert_eq!(snap_dry_run.tree, first_snapshot.tree);
let packs: Vec<_> = repo.list(rustic_core::FileType::Pack)?.collect();

// // tree of first backup
// // re-read index
// let repo = repo.to_indexed_ids()?;
// let tree = repo.node_from_path(first_snapshot.tree, Path::new("test/tests"))?;
// let tree = repo.get_tree(&tree.subtree.expect("Sub tree"))?;
// tree of first backup
// re-read index
let repo = repo.to_indexed_ids()?;
let tree = repo.node_from_path(first_snapshot.tree, Path::new("test/0/tests"))?;
let tree = repo.get_tree(&tree.subtree.expect("Sub tree"))?;

// #[cfg(windows)]
// assert_debug_snapshot!("dryrun-tar-tree-windows", tree);
#[cfg(windows)]
assert_debug_snapshot!("dryrun-tar-tree-windows", tree);

// #[cfg(not(windows))]
// assert_debug_snapshot!("dryrun-tar-tree-nix", tree);
#[cfg(not(windows))]
assert_debug_snapshot!("dryrun-tar-tree-nix", tree);

// re-read index
let repo = repo.to_indexed_ids()?;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1d359cf

Please sign in to comment.