summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2017-03-12 16:41:47 +0100
committerFlorian Pritz <bluewind@xinu.at>2017-03-12 16:41:47 +0100
commit18f143459991e44e10137fed501d162ae54274f8 (patch)
tree7a7afffc2187eb632ee2fbe1c7f0c9a3572e0d09 /t
parent1d3ab4fee5071def96767a3808f7366e2d8570a1 (diff)
downloadApp-BorgRestore-18f143459991e44e10137fed501d162ae54274f8.tar.gz
App-BorgRestore-18f143459991e44e10137fed501d162ae54274f8.tar.xz
Fix sort order of detected archives
cmp sorts strings, <=> sorts numbers Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 't')
-rw-r--r--t/04_find_archives.t29
1 files changed, 29 insertions, 0 deletions
diff --git a/t/04_find_archives.t b/t/04_find_archives.t
new file mode 100644
index 0000000..2d40eef
--- /dev/null
+++ b/t/04_find_archives.t
@@ -0,0 +1,29 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::MockObject;
+use Test::Differences;
+
+use App::BorgRestore;
+
+my $db = Test::MockObject->new();
+$db->mock('get_archives_for_path', sub {return [
+ { modification_time => 5, archive => "test2"},
+ { modification_time => 2, archive => "test1"},
+ { modification_time => 10, archive => "test3"},
+ { modification_time => 10, archive => "test4"},
+ { modification_time => 2, archive => "test1-1"},
+ { modification_time => 15, archive => "test5"},
+ ];});
+
+my $app = App::BorgRestore->new_no_defaults({}, {db => $db});
+
+eq_or_diff($app->find_archives('test/path'), [
+ {archive => 'test1', modification_time => 2},
+ {archive => 'test2', modification_time => 5},
+ {archive => 'test3', modification_time => 10},
+ {archive => 'test5', modification_time => 15},
+]);
+
+done_testing;