summaryrefslogtreecommitdiffstats
path: root/t/find_archives_mocked.t
blob: 06e5a6f85a271c23e4456f5e30ab3d8e411293a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use strictures 2;

use Log::Any::Adapter ('TAP');
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;