root/tags/1.05/t/03-combine-little-files.t

Revision 157, 1.2 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 tests => 15;
5
6use Brackup::Test;
7use FindBin qw($Bin);
8use Brackup::Util qw(tempfile);
9
10############### Backup
11
12my ($digdb_fh, $digdb_fn) = tempfile();
13close($digdb_fh);
14my $root_dir = "$Bin/data";
15ok(-d $root_dir, "test data to backup exists");
16
17my ($backup_file, $backup) =
18    do_backup(
19              with_confsec => sub {
20                  my $csec = shift;
21                  $csec->add("path",          $root_dir);
22                  $csec->add("merge_files_under",    "1k");
23                  $csec->add("max_composite_chunk_size",  "500k");
24                  $csec->add("digestdb_file", $digdb_fn);
25              },
26              );
27
28# see if dup files were only stored once
29my %seen;
30$backup->foreach_saved_file(sub {
31    my ($file, $slist) = @_;
32    return unless $file->path =~ /000-dup[12]\.txt$/;
33    foreach my $sc (@$slist) {
34        $seen{$sc->to_meta}++;
35    }
36});
37is(scalar keys %seen, 1, "stored just one uniq copy of 000-dup[12]");
38is((%seen)[-1], 2, "and stored it twice");
39like((%seen)[0], qr/-/, "and it was stored in a range");
40
41
42
43############### Restore
44
45my $restore_dir = do_restore($backup_file);
46
47ok_dirs_match($restore_dir, $root_dir);
48
Note: See TracBrowser for help on using the browser.