summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2018-08-19 11:16:46 +0200
committerFlorian Pritz <bluewind@xinu.at>2018-08-19 11:16:46 +0200
commitd201df23d920e0f481895ce933f3c35fff708150 (patch)
tree570b89db6c14a098400f7de5bab8685d40e2d050
parent015acd1c4a693a06b5ad800e91b4175f2249ec01 (diff)
downloadApp-BorgRestore-d201df23d920e0f481895ce933f3c35fff708150.tar.gz
App-BorgRestore-d201df23d920e0f481895ce933f3c35fff708150.tar.xz
Add search_path and find_archives integration tests
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--META.json1
-rw-r--r--cpanfile1
-rw-r--r--t/08_search_path.t39
-rw-r--r--t/09_find_archives.t50
4 files changed, 91 insertions, 0 deletions
diff --git a/META.json b/META.json
index b4de313..f550c31 100644
--- a/META.json
+++ b/META.json
@@ -69,6 +69,7 @@
},
"test" : {
"requires" : {
+ "Log::Any::Adapter::TAP" : "0",
"Software::License::GPL_3" : "0",
"Test::Differences" : "0",
"Test::Exception" : "0",
diff --git a/cpanfile b/cpanfile
index 64217f4..0229b16 100644
--- a/cpanfile
+++ b/cpanfile
@@ -27,6 +27,7 @@ on configure => sub {
};
on 'test' => sub {
+ requires 'Log::Any::Adapter::TAP';
requires 'Test::Differences';
requires 'Test::Exception';
requires 'Test::MockObject';
diff --git a/t/08_search_path.t b/t/08_search_path.t
new file mode 100644
index 0000000..ef6901c
--- /dev/null
+++ b/t/08_search_path.t
@@ -0,0 +1,39 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::MockObject;
+use Test::Differences;
+
+use App::BorgRestore;
+use App::BorgRestore::DB;
+use Log::Any::Adapter ('TAP');
+
+my $db = App::BorgRestore::DB->new(":memory:", 0);
+my $app = App::BorgRestore->new_no_defaults({db => $db});
+
+$db->add_archive_name("test1");
+my $archive_id1 = $db->get_archive_id("test1");
+$db->add_archive_name("test2");
+my $archive_id2 = $db->get_archive_id("test2");
+$db->add_archive_name("test3");
+my $archive_id3 = $db->get_archive_id("test3");
+$db->add_archive_name("test4");
+my $archive_id4 = $db->get_archive_id("test4");
+
+$db->add_path($archive_id1, "test/path", 5);
+$db->add_path($archive_id1, "test/foo", 4);
+$db->add_path($archive_id1, "test", 5);
+
+$db->add_path($archive_id2, "test/path", 5);
+$db->add_path($archive_id2, "test", 5);
+
+$db->add_path($archive_id3, "test/path", 10);
+$db->add_path($archive_id3, "test/foo", 4);
+$db->add_path($archive_id3, "test", 10);
+
+eq_or_diff($app->search_path("test"), ['test', 'test/foo', 'test/path']);
+eq_or_diff($app->search_path("test%"), ['test', 'test/foo', 'test/path']);
+eq_or_diff($app->search_path("%foo"), ['test/foo']);
+
+done_testing;
diff --git a/t/09_find_archives.t b/t/09_find_archives.t
new file mode 100644
index 0000000..eebea6c
--- /dev/null
+++ b/t/09_find_archives.t
@@ -0,0 +1,50 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::MockObject;
+use Test::Differences;
+use Test::Exception;
+
+use App::BorgRestore;
+use App::BorgRestore::DB;
+use Log::Any::Adapter ('TAP');
+
+my $db = App::BorgRestore::DB->new(":memory:", 0);
+
+my $app = App::BorgRestore->new_no_defaults({db => $db});
+
+$db->add_archive_name("test1");
+my $archive_id1 = $db->get_archive_id("test1");
+$db->add_archive_name("test2");
+my $archive_id2 = $db->get_archive_id("test2");
+$db->add_archive_name("test3");
+my $archive_id3 = $db->get_archive_id("test3");
+$db->add_archive_name("test4");
+my $archive_id4 = $db->get_archive_id("test4");
+
+$db->add_path($archive_id1, "test/path", 5);
+$db->add_path($archive_id1, "test/foo", 4);
+$db->add_path($archive_id1, "test", 5);
+
+$db->add_path($archive_id2, "test/path", 5);
+$db->add_path($archive_id2, "test", 5);
+
+$db->add_path($archive_id3, "test/path", 10);
+$db->add_path($archive_id3, "test/foo", 4);
+$db->add_path($archive_id3, "test", 10);
+
+eq_or_diff($app->find_archives('test/path'), [
+ {
+ archive => 'test1',
+ modification_time => 5
+ },
+ {
+ archive => 'test3',
+ modification_time => 10
+ },
+ ]);
+
+dies_ok {$app->find_archives('test/nope')};
+
+done_testing;