1 | # $Id$ |
---|
2 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | |
---|
6 | use Test::More tests => 14; |
---|
7 | use File::Temp qw(tempdir); |
---|
8 | |
---|
9 | use_ok('ObsData'); |
---|
10 | use_ok('ObsData::Repository'); |
---|
11 | |
---|
12 | my $o = ObsData->new('testdata/obsdata-conftest', logfile => "testdata/obsdata.log"); |
---|
13 | |
---|
14 | { |
---|
15 | my $or = ObsData::Repository::dir->new( |
---|
16 | { |
---|
17 | obsdata => $o, |
---|
18 | dir => 'testdata/ohp', |
---|
19 | } |
---|
20 | ); |
---|
21 | |
---|
22 | isa_ok($or, "ObsData::Repository::dir"); |
---|
23 | ok($or->logging(0, "FOO%s", "FOO") eq "FOOFOO", "logging return the message properly"); |
---|
24 | ok($or->findfile, "can find file"); |
---|
25 | } |
---|
26 | |
---|
27 | { |
---|
28 | my $callbackwhy; |
---|
29 | my $or = ObsData::Repository::dir::archive->new( |
---|
30 | { |
---|
31 | obsdata => $o, |
---|
32 | dir => 'testdata/ohp', |
---|
33 | archivefile => 'ozone34.gz', |
---|
34 | interative_callback => sub { |
---|
35 | my ($self, $event) = @_; |
---|
36 | $callbackwhy = $event->id; |
---|
37 | if ($callbackwhy eq 'overwrite') { |
---|
38 | return 1; |
---|
39 | } else { |
---|
40 | return $self->default_choice($event); |
---|
41 | } |
---|
42 | }, |
---|
43 | } |
---|
44 | ); |
---|
45 | isa_ok($or, "ObsData::Repository::dir::archive"); |
---|
46 | ok($or->load_archive, "Can load an archive"); |
---|
47 | |
---|
48 | # ini status checks |
---|
49 | $or->setvalue('FOO', 'FOO'); |
---|
50 | $or->set_data_value('ozone34', 'BAR', 'BAR'); |
---|
51 | ok($or->getvalue('FOO') eq 'FOO', "can get a value"); |
---|
52 | ok($or->get_data_value('ozone34', 'BAR') eq 'BAR', "can get a value"); |
---|
53 | |
---|
54 | ok($or->do_continue('overwrite', 'a', 'a') eq 1, "Perform do_continue"); |
---|
55 | ok($callbackwhy eq 'overwrite', "arg are properly passed to callback"); |
---|
56 | ok($or->list_archive, "Can list archive content"); |
---|
57 | ok($or->get_data_dest('ozone34'), "Can get data destination"); |
---|
58 | ok($or->extract_data('ozone34', undef, '/dev/null'), "Can extract data"); |
---|
59 | } |
---|
60 | |
---|