summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2018-09-06 18:30:18 +0200
committerFlorian Pritz <bluewind@xinu.at>2018-09-06 18:30:18 +0200
commit3ac772e2a254d8d8f3df3af4a0e6836905caba46 (patch)
tree1f1f917faa10d179e0da03d8792684f5baf6d3c8
parentfdf1bd5df30e245ba051c3341e3903a967d62dbb (diff)
downloadApp-BorgRestore-3ac772e2a254d8d8f3df3af4a0e6836905caba46.tar.gz
App-BorgRestore-3ac772e2a254d8d8f3df3af4a0e6836905caba46.tar.xz
Test handled_added_archives with Memory and DB storage
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--t/handle_added_archives_with_db.t65
1 files changed, 35 insertions, 30 deletions
diff --git a/t/handle_added_archives_with_db.t b/t/handle_added_archives_with_db.t
index e0c44ce..7bb3106 100644
--- a/t/handle_added_archives_with_db.t
+++ b/t/handle_added_archives_with_db.t
@@ -7,36 +7,41 @@ use Test::MockObject;
use Test::More;
use App::BorgRestore;
-
-my $db = App::BorgRestore::DB->new(":memory:", 0);
-
-$ENV{TZ} = 'UTC';
-tzset;
-
-my $borg = Test::MockObject->new();
-$borg->set_list('borg_list', ['archive-1']);
-$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");
- } );
-
-# Call the actual function we want to test
-my $app = App::BorgRestore->new({borg => $borg, db => $db});
-$app->_handle_added_archives(['archive-1']);
-
-# check database content
-eq_or_diff($db->get_archives_for_path('boot'), [{archive => 'archive-1', modification_time => 20},]);
-eq_or_diff($db->get_archives_for_path('boot/foo'), [{archive => 'archive-1', modification_time => 19},]);
-eq_or_diff($db->get_archives_for_path('boot/foo/bar'), [{archive => 'archive-1', modification_time => 19},]);
-eq_or_diff($db->get_archives_for_path('boot/foo/blub'), [{archive => 'archive-1', modification_time => 13},]);
-eq_or_diff($db->get_archives_for_path('boot/grub'), [{archive => 'archive-1', modification_time => 20},]);
-eq_or_diff($db->get_archives_for_path('boot/grub/grub.cfg'), [{archive => 'archive-1', modification_time => 8},]);
+use App::BorgRestore::Settings;
+
+for my $in_memory (0,1) {
+ $App::BorgRestore::Settings::prepare_data_in_memory = $in_memory;
+
+ my $db = App::BorgRestore::DB->new(":memory:", 0);
+
+ $ENV{TZ} = 'UTC';
+ tzset;
+
+ my $borg = Test::MockObject->new();
+ $borg->set_list('borg_list', ['archive-1']);
+ $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");
+ } );
+
+ # Call the actual function we want to test
+ my $app = App::BorgRestore->new({borg => $borg, db => $db});
+ $app->_handle_added_archives(['archive-1']);
+
+ # check database content
+ eq_or_diff($db->get_archives_for_path('boot'), [{archive => 'archive-1', modification_time => 20},]);
+ eq_or_diff($db->get_archives_for_path('boot/foo'), [{archive => 'archive-1', modification_time => 19},]);
+ eq_or_diff($db->get_archives_for_path('boot/foo/bar'), [{archive => 'archive-1', modification_time => 19},]);
+ eq_or_diff($db->get_archives_for_path('boot/foo/blub'), [{archive => 'archive-1', modification_time => 13},]);
+ eq_or_diff($db->get_archives_for_path('boot/grub'), [{archive => 'archive-1', modification_time => 20},]);
+ eq_or_diff($db->get_archives_for_path('boot/grub/grub.cfg'), [{archive => 'archive-1', modification_time => 8},]);
+}
done_testing;