Skip to content

Commit 2d702dd

Browse files
author
tkuestner
committed
Merge remote-tracking branch 'upstream/main'
2 parents fa1e329 + fd7eacb commit 2d702dd

File tree

6 files changed

+42
-16
lines changed

6 files changed

+42
-16
lines changed

src/backup.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,11 @@ mod tests {
475475
assert_eq!(stats.compressed_bytes, 8);
476476

477477
// Will vary depending on compressor and we don't want to be too brittle.
478-
assert!(stats.compressed_bytes <= 19, stats.compressed_bytes);
478+
assert!(
479+
stats.compressed_bytes <= 19,
480+
"too many compressed_bytes: {}",
481+
stats.compressed_bytes
482+
);
479483

480484
// Try to read back
481485
let (back, sizes) = block_dir.get(&addrs[0]).unwrap();

src/band.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ mod tests {
327327

328328
let e = Band::open(&af, &BandId::zero());
329329
let e_str = e.unwrap_err().to_string();
330-
assert!(e_str.contains("Band version \"0.8.8\" in"), e_str);
330+
assert!(
331+
e_str.contains("Band version \"0.8.8\" in"),
332+
"bad band version: {:#?}",
333+
e_str
334+
);
331335
}
332336
}

src/live_tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ mod tests {
397397

398398
let repr = format!("{:?}", &result[6]);
399399
let re = Regex::new(r#"LiveEntry \{ apath: Apath\("/jam/apricot"\), kind: File, mtime: UnixTime \{ [^)]* \}, size: Some\(8\), symlink_target: None \}"#).unwrap();
400-
assert!(re.is_match(&repr), repr);
400+
assert!(re.is_match(&repr));
401401

402402
// TODO: Somehow get the stats out of the iterator.
403403
// assert_eq!(source_iter.stats.directories_visited, 4);

src/progress.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ impl ProgressBar {
161161
self.percent
162162
} else if self.total_work > 0 && self.work_done > 0 {
163163
Some(100f64 * self.work_done as f64 / self.total_work as f64)
164+
} else if self.bytes_total > 0 && self.bytes_done > 0 {
165+
Some(100f64 * self.bytes_done as f64 / self.bytes_total as f64)
164166
} else {
165167
None
166168
}

tests/delete.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2015, 2016, 2017, 2019, 2020 Martin Pool.
2+
3+
// This program is free software; you can redistribute it and/or modify
4+
// it under the terms of the GNU General Public License as published by
5+
// the Free Software Foundation; either version 2 of the License, or
6+
// (at your option) any later version.
7+
//
8+
// This program is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// GNU General Public License for more details.
12+
13+
//! Test deletion.
14+
15+
use conserve::test_fixtures::ScratchArchive;
16+
use conserve::*;
17+
18+
#[test]
19+
fn delete_all_bands() {
20+
let af = ScratchArchive::new();
21+
af.store_two_versions();
22+
23+
let stats = af
24+
.delete_bands(&[BandId::new(&[0]), BandId::new(&[1])], &Default::default())
25+
.expect("delete_bands");
26+
27+
assert_eq!(stats.deleted_block_count, 2);
28+
assert_eq!(stats.deleted_band_count, 2);
29+
}

tests/integration.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -381,16 +381,3 @@ pub fn detect_minimal_mtime_change() {
381381
assert_eq!(stats.files, 2);
382382
assert_eq!(stats.unmodified_files, 1);
383383
}
384-
385-
#[test]
386-
fn delete_bands() {
387-
let af = ScratchArchive::new();
388-
af.store_two_versions();
389-
390-
let stats = af
391-
.delete_bands(&[BandId::new(&[0]), BandId::new(&[1])], &Default::default())
392-
.expect("delete_bands");
393-
394-
assert_eq!(stats.deleted_block_count, 2);
395-
assert_eq!(stats.deleted_band_count, 2);
396-
}

0 commit comments

Comments
 (0)