summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2018-09-09 18:04:35 +0200
committerFlorian Pritz <bluewind@xinu.at>2018-09-09 18:05:10 +0200
commit4d326930a84561f9ab4a530f67dafe042422435e (patch)
tree08d2e88cf551af952bd9b21a6b912290af1becb7
parent33442edce73d2be8e8210af992e0ec5803d32a6e (diff)
downloadApp-BorgRestore-4d326930a84561f9ab4a530f67dafe042422435e.tar.gz
App-BorgRestore-4d326930a84561f9ab4a530f67dafe042422435e.tar.xz
Test if adding an archive updates existing rows correctly
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--t/handle_added_archives_with_db.t79
1 files changed, 79 insertions, 0 deletions
diff --git a/t/handle_added_archives_with_db.t b/t/handle_added_archives_with_db.t
index e090e25..c8b0ff8 100644
--- a/t/handle_added_archives_with_db.t
+++ b/t/handle_added_archives_with_db.t
@@ -51,6 +51,85 @@ for my $in_memory (0,1) {
eq_or_diff($db->get_archives_for_path('boot/test1/f3'), [{archive => 'archive-1', modification_time => 3},]);
eq_or_diff($db->get_archives_for_path('boot/test1/f4'), [{archive => 'archive-1', modification_time => 2},]);
eq_or_diff($db->get_archives_for_path('lulz'), [{archive => 'archive-1', modification_time => undef},]);
+
+
+ # add second archive
+ $borg->set_list('borg_list', ['archive-1', 'archive-2']);
+ $borg->mock('list_archive', sub {
+ my ($self, $archive, $cb) = @_;
+ $cb->("XXX, 1970-01-01 00:00:05 .");
+ $cb->("XXX, 1970-01-01 00:00:10 boot");
+ $cb->("XXX, 1970-01-01 00:00:20 boot/grub");
+ $cb->("XXX, 1970-01-01 00:00:08 boot/grub/grub.cfg");
+ $cb->("XXX, 1970-01-01 00:00:13 boot/foo");
+ $cb->("XXX, 1970-01-01 00:00:13 boot/foo/blub");
+ $cb->("XXX, 1970-01-01 00:00:19 boot/foo/bar");
+ $cb->("XXX, 1970-01-01 00:00:02 boot/test1");
+ $cb->("XXX, 1970-01-01 00:00:03 boot/test1/f1");
+ $cb->("XXX, 1970-01-01 00:00:05 boot/test1/f2");
+ $cb->("XXX, 1970-01-01 00:00:03 boot/test1/f3");
+ $cb->("XXX, 1970-01-01 00:00:02 boot/test1/f4");
+ $cb->("XXX, 1970-01-01 00:00:07 boot/test1/f5");
+ } );
+ $app->_handle_added_archives(['archive-2']);
+
+ # check database content
+ eq_or_diff($db->get_archives_for_path('.'), [
+ {archive => 'archive-1', modification_time => undef},
+ {archive => 'archive-2', modification_time => undef},
+ ]);
+ eq_or_diff($db->get_archives_for_path('boot'), [
+ {archive => 'archive-1', modification_time => 20},
+ {archive => 'archive-2', modification_time => 20},
+ ]);
+ eq_or_diff($db->get_archives_for_path('boot/foo'), [
+ {archive => 'archive-1', modification_time => 19},
+ {archive => 'archive-2', modification_time => 19},
+ ]);
+ eq_or_diff($db->get_archives_for_path('boot/foo/bar'), [
+ {archive => 'archive-1', modification_time => 19},
+ {archive => 'archive-2', modification_time => 19},
+ ]);
+ eq_or_diff($db->get_archives_for_path('boot/foo/blub'), [
+ {archive => 'archive-1', modification_time => 13},
+ {archive => 'archive-2', modification_time => 13},
+ ]);
+ eq_or_diff($db->get_archives_for_path('boot/grub'), [
+ {archive => 'archive-1', modification_time => 20},
+ {archive => 'archive-2', modification_time => 20},
+ ]);
+ eq_or_diff($db->get_archives_for_path('boot/grub/grub.cfg'), [
+ {archive => 'archive-1', modification_time => 8},
+ {archive => 'archive-2', modification_time => 8},
+ ]);
+ eq_or_diff($db->get_archives_for_path('boot/test1'), [
+ {archive => 'archive-1', modification_time => 4},
+ {archive => 'archive-2', modification_time => 7},
+ ]);
+ eq_or_diff($db->get_archives_for_path('boot/test1/f1'), [
+ {archive => 'archive-1', modification_time => 3},
+ {archive => 'archive-2', modification_time => 3},
+ ]);
+ eq_or_diff($db->get_archives_for_path('boot/test1/f2'), [
+ {archive => 'archive-1', modification_time => 4},
+ {archive => 'archive-2', modification_time => 5},
+ ]);
+ eq_or_diff($db->get_archives_for_path('boot/test1/f3'), [
+ {archive => 'archive-1', modification_time => 3},
+ {archive => 'archive-2', modification_time => 3},
+ ]);
+ eq_or_diff($db->get_archives_for_path('boot/test1/f4'), [
+ {archive => 'archive-1', modification_time => 2},
+ {archive => 'archive-2', modification_time => 2},
+ ]);
+ eq_or_diff($db->get_archives_for_path('boot/test1/f5'), [
+ {archive => 'archive-1', modification_time => undef},
+ {archive => 'archive-2', modification_time => 7},
+ ]);
+ eq_or_diff($db->get_archives_for_path('lulz'), [
+ {archive => 'archive-1', modification_time => undef},
+ {archive => 'archive-2', modification_time => undef},
+ ]);
}