root/tags/1.05/t/02-gpg.t

Revision 157, 1.4 kB (checked in by bradfitz, 2 years ago)

make tests pass on OS X (Jesse Vincent)

Line 
1# -*-perl-*-
2
3use strict;
4use Test::More;
5
6use Brackup::Test;
7use FindBin qw($Bin);
8use Brackup::Util qw(tempfile);
9
10############### Backup
11
12if (`gpg --version`) {
13    plan tests => 12;
14} else {
15    plan skip_all => 'gpg binary not found, skipping encrypted tests';
16}
17
18my $gpg_args = ["--no-default-keyring",
19                "--keyring=$Bin/data/pubring-test.gpg",
20                "--secret-keyring=$Bin/data/secring-test.gpg"];
21
22my ($digdb_fh, $digdb_fn) = tempfile();
23close($digdb_fh);
24my $root_dir = "$Bin/data";
25ok(-d $root_dir, "test data to backup exists");
26
27my $backup_file = do_backup(
28                            with_confsec => sub {
29                                my $csec = shift;
30                                $csec->add("path",          $root_dir);
31                                $csec->add("chunk_size",    "2k");
32                                $csec->add("digestdb_file", $digdb_fn);
33                                $csec->add("gpg_recipient", "2149C469");
34                            },
35                            with_root => sub {
36                                my $root = shift;
37                                $root->{gpg_args} = $gpg_args;
38                            },
39                            );
40
41############### Restore
42
43my $restore_dir = do {
44    local @Brackup::GPG_ARGS = @$gpg_args;
45    do_restore($backup_file);
46};
47
48ok_dirs_match($restore_dir, $root_dir);
49
Note: See TracBrowser for help on using the browser.