root/tags/1.05/t/04-gc.t

Revision 162, 1.1 kB (checked in by bradfitz, 2 years ago)

Checking in changes prior to tagging of version 1.05. Changelog diff is:

Index: Changes
===================================================================
--- Changes (revision 161)
+++ Changes (working copy)
@@ -1,3 +1,5 @@
+1.05 (august 2, 2007)
+

  • 'prune' and 'gc' commands commands for both Amazon

and Filesystem targets. from Alessandro Ranellucci <aar@…>.


Line 
1# -*-perl-*-
2
3use strict;
4use Test::More tests => 9;
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");
16my ($backup_file, $backup, $target) = do_backup(
17                            with_confsec => sub {
18                                my $csec = shift;
19                                $csec->add("path",          $root_dir);
20                                $csec->add("chunk_size",    "2k");
21                                $csec->add("digestdb_file", $digdb_fn);
22                            },
23                            );
24
25############### Add an orphan chunk
26
27my $orphan_chunks_count = int(rand 10);
28for (1..$orphan_chunks_count) {
29    my $chunk = Brackup::StoredChunk->new;
30    $chunk->{_chunkref} = \ "foobar $_";
31    $target->store_chunk($chunk);
32}
33
34############### Do garbage collection
35
36my $removed_count = $target->gc;
37ok($removed_count == $orphan_chunks_count, "all orphan chunks removed");
38
39__END__
Note: See TracBrowser for help on using the browser.