]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/perl | |
2 | use strict; | |
3 | use warnings; | |
4 | ||
5 | use Test::More tests => 23; | |
6 | BEGIN { use_ok('Zeal::Feed') }; | |
7 | ||
8 | my $feed = Zeal::Feed->new_from_file('t/feed.xml'); | |
9 | is $feed->version, '1.2.3', 'feed version is 1.2.3'; | |
10 | my @urls = sort $feed->urls; | |
11 | my $url_re = qr,^http://srv[12]\.example\.com/feed\.tar\.gz$,; | |
12 | like $urls[$_-1], $url_re, "feed url $_ is correct" for 1, 2; | |
13 | like $feed->url, $url_re, 'feed random url is correct'; | |
14 | ||
15 | use File::Temp qw/tempdir/; | |
16 | ||
17 | sub test_unpack { | |
18 | my ($arch) = @_; | |
19 | my $dir = tempdir 'zeal-testXXXX', TMPDIR => 1, CLEANUP => 1; | |
20 | note "Testing unpack of $arch"; | |
21 | Zeal::Feed::_unpack_tar_to_dir($arch, $dir); | |
22 | ok -d "$dir/a.docset", 'Root directory of unpacked docset exists'; | |
23 | ok -f "$dir/a.docset/Contents/Info.plist", 'Info.plist exists'; | |
24 | } | |
25 | ||
26 | note "Testing unpack with default tar"; | |
27 | test_unpack $_ for 't/a.tar', 't/a.tar.gz', 't/a.tar.bz2'; | |
28 | note "Testing unpack with Archive::Tar by env variable"; | |
29 | $ENV{ZEAL_USE_INTERNAL_TAR} = 1; | |
30 | test_unpack $_ for 't/a.tar', 't/a.tar.gz', 't/a.tar.bz2'; | |
31 | note "Testing unpack with Archive::Tar by clearing PATH"; | |
32 | $ENV{ZEAL_USE_INTERNAL_TAR} = 0; | |
33 | $ENV{PATH} = ''; | |
34 | test_unpack $_ for 't/a.tar', 't/a.tar.gz', 't/a.tar.bz2'; |