test(store): damaged pieces are repaired, a drill never passes on an older backup, books ahead and diverged, a disk with no links, headers, sync stand-ins, a destination of 3000 backups
Each test fails without the change it covers: the reviewer's sequence (a byte flipped in backup 2's segment, more backups, a drill, a restore), a damaged stored file found by the rotating share, a drill that must fail when only an older manifest is whole, ahead told from diverged with a new set beside the old, the no-link path (and two writers racing on it), sealed pieces in folders, header settings capped and authenticated, one key derivation per setting, files not downloaded yet, vault scratch files, and a destination of 3000 backups made cheaply (12 MB of manifests, 0.8 KB for the newest, 32 ms to find and read it). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
6a8dc6c88b
commit
9ac47a3f10
8 files changed
+1578
-51
No files matched your search
@@ -67,12 +67,14 @@ mod io;
|
||||
mod read;
|
||||
mod seal;
|
||||
mod single;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
mod write;
|
||||
|
||||
pub use cut::Cut;
|
||||
pub use read::list;
|
||||
pub use read::{Candidate, Found, Verified, drill, find, prove_local, verify_found};
|
||||
pub use seal::BackupKey;
|
||||
pub use seal::{BackupKey, key_derivations};
|
||||
pub use single::{FILE_EXTENSION, save_file};
|
||||
pub use write::{
|
||||
Destination, Options, Written, holds_only_sealed, set_name_for, write_destination,
|
||||
@@ -223,8 +225,16 @@ pub struct Ctx {
|
||||
/// refuse to replace.
|
||||
no_links: bool,
|
||||
no_noreplace: bool,
|
||||
/// Tests: nothing is synced to disk (a destination of thousands of
|
||||
/// backups is made quickly; a real one never is).
|
||||
no_sync: bool,
|
||||
/// Tests: told each read and length look at a file of the set.
|
||||
trace: Option<Trace>,
|
||||
}
|
||||
|
||||
/// A test's look at which files of a set are read or measured.
|
||||
pub type Trace = Arc<dyn Fn(&str, &str) + Send + Sync>;
|
||||
|
||||
impl std::fmt::Debug for Ctx {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str("Ctx")
|
||||
@@ -267,6 +277,30 @@ impl Ctx {
|
||||
self
|
||||
}
|
||||
|
||||
/// Told, in tests, each `read` and `len` of a file of a set.
|
||||
#[doc(hidden)]
|
||||
pub fn with_trace(mut self, trace: Trace) -> Self {
|
||||
self.trace = Some(trace);
|
||||
self
|
||||
}
|
||||
|
||||
pub(crate) fn traced(&self, kind: &str, rel: &str) {
|
||||
if let Some(t) = &self.trace {
|
||||
t(kind, rel);
|
||||
}
|
||||
}
|
||||
|
||||
/// Nothing is synced to disk (tests that make thousands of backups).
|
||||
#[doc(hidden)]
|
||||
pub fn with_no_sync(mut self) -> Self {
|
||||
self.no_sync = true;
|
||||
self
|
||||
}
|
||||
|
||||
pub(crate) fn syncs(&self) -> bool {
|
||||
!self.no_sync
|
||||
}
|
||||
|
||||
pub(crate) fn refuses_links(&self) -> bool {
|
||||
self.no_links
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user