From adb8c7927a60a9023c48290a606b749d26c48515 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Tue, 30 Dec 2014 23:11:38 +0200 Subject: [PATCH] Add tests for Zeal::Feed --- MANIFEST | 5 +++++ t/Zeal-Feed.t | 34 ++++++++++++++++++++++++++++++++++ t/a.tar | Bin 0 -> 10240 bytes t/a.tar.bz2 | Bin 0 -> 823 bytes t/a.tar.gz | Bin 0 -> 752 bytes t/feed.xml | 5 +++++ 6 files changed, 44 insertions(+) create mode 100644 t/Zeal-Feed.t create mode 100644 t/a.tar create mode 100644 t/a.tar.bz2 create mode 100644 t/a.tar.gz create mode 100644 t/feed.xml diff --git a/MANIFEST b/MANIFEST index 4ca629c..a7300bd 100644 --- a/MANIFEST +++ b/MANIFEST @@ -6,6 +6,9 @@ lib/Zeal/Feed.pm Makefile.PL MANIFEST README +t/a.tar +t/a.tar.bz2 +t/a.tar.gz t/ds/a.docset/Contents/Info.plist t/ds/a.docset/Contents/Resources/docSet.dsidx t/ds/a.docset/Contents/Resources/Documents/about.html @@ -19,7 +22,9 @@ t/ds/c.docset/Contents/Resources/docSet.dsidx t/ds/c.docset/Contents/Resources/Documents/category.html t/ds/c.docset/Contents/Resources/Documents/class.html t/ds/dummy-file +t/feed.xml t/mkindex.pl t/perlcritic.t t/perlcriticrc t/Zeal.t +t/Zeal-Feed.t diff --git a/t/Zeal-Feed.t b/t/Zeal-Feed.t new file mode 100644 index 0000000..9113bc9 --- /dev/null +++ b/t/Zeal-Feed.t @@ -0,0 +1,34 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Test::More tests => 23; +BEGIN { use_ok('Zeal::Feed') }; + +my $feed = Zeal::Feed->new_from_file('t/feed.xml'); +is $feed->version, '1.2.3', 'feed version is 1.2.3'; +my @urls = sort $feed->urls; +my $url_re = qr,^http://srv[12]\.example\.com/feed\.tar\.gz$,; +like $urls[$_-1], $url_re, "feed url $_ is correct" for 1, 2; +like $feed->url, $url_re, 'feed random url is correct'; + +use File::Temp qw/tempdir/; + +sub test_unpack { + my ($arch) = @_; + my $dir = tempdir 'zeal-testXXXX', TMPDIR => 1, CLEANUP => 1; + note "Testing unpack of $arch"; + Zeal::Feed::_unpack_tar_to_dir($arch, $dir); + ok -d "$dir/a.docset", 'Root directory of unpacked docset exists'; + ok -f "$dir/a.docset/Contents/Info.plist", 'Info.plist exists'; +} + +note "Testing unpack with default tar"; +test_unpack $_ for 't/a.tar', 't/a.tar.gz', 't/a.tar.bz2'; +note "Testing unpack with Archive::Tar by env variable"; +$ENV{ZEAL_USE_INTERNAL_TAR} = 1; +test_unpack $_ for 't/a.tar', 't/a.tar.gz', 't/a.tar.bz2'; +note "Testing unpack with Archive::Tar by clearing PATH"; +$ENV{ZEAL_USE_INTERNAL_TAR} = 0; +$ENV{PATH} = ''; +test_unpack $_ for 't/a.tar', 't/a.tar.gz', 't/a.tar.bz2'; diff --git a/t/a.tar b/t/a.tar new file mode 100644 index 0000000000000000000000000000000000000000..362cc8c49f49369d2550cb3fdce650b0c438b4fb GIT binary patch literal 10240 zcmeHNPfy!06n7F3TBRK)*v%^!kf2T4q}idA6$n!`hM*J;b~BBk*3tweF3{ty`)u$v z*w@%|(n2W%3bagR_91??pa1aty=VK`kc=DDBg(UAbV-L~TNZ-Mur0ke7gZu5BWGH= zZkYwWfOI2gm^p;4(M{>P=T^i?h%suCkhP-g@_y-|`hNW}`Axd~uLeG+K95FV2!h~2 z`L_+hf8I6?$^T23&~5&!GzwZ_oes|u9>KqzGX?*aZJ3h(f6YJa3_Fx(+=#hn&zXzh zzhIiZ>wb41h^ye!UH=pQbGlI|Agn)U&_Ub&=j;E@_6Fk=9|mEQaGXaINKw!y*bfni z2x&bqs-3cKkEY2ss zd5*M8?R;!$krS5)NCeP~I*F#=eIN%xi+>A3Hx@Dt-t=aaq$UhWJFXEzT$2LaRP6$3 z7us(Lp+rC;FvbYHp9J?;{^I}YjHr1-Zu|dz@&8&-Z#9Q-CnSQr0q=h-BMGjsFw=b4CHKfn@yu6tExJrYx2O%py$iDI6K_ z0X<^A&-^2N${EQnstpD=x&=L%cWE?Hi(;gQ0lTehwKM!msZzTTE6Si ziVG0~J7hF0W<`0b81WD~E0JQhBi(GU2{)8|s^vaa2t?o^YRe;Byi=@`CiB{TO-_PS z>P3C+ShPl>2DFBMa7grvJZ#ZyshI7|JRARArIcLS?luuwBN31YNCYGTuMmMhpQhJO literal 0 HcmV?d00001 diff --git a/t/a.tar.bz2 b/t/a.tar.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..41454e8651873d4b287542d354c2b98923aceffe GIT binary patch literal 823 zcmV-71IYYBT4*^jL0KkKS%HIyH2?x2|Ihxi1K{{)|JVPoe(-hG&D3aGy@4Gld& z(9jxW0009`Jw;yN7RfAr3`#*zKayY!5yK>6TDI~n0gazVAQDhur;ex@m`1SMaL#AX z2-S26#sUF!Cg4m@%FV6zz8QR4-PRrPIIs#;(` zT|on*vq{>hh3O#(rJkKV$*+f>vRE`ddWg#(65cBOiG3v*aYlFIE~n6fs|`E}w^ zir=vb7-n*b#=RJ+(WfNZOMw%vrvW;+fKQ@=B3AYy5&2&x7IC$_)?AeL5Fr4%(RRkc@%g#()8Qp!lRT6tYb zDHMo|=FW3M=Fs^%u+bbZsZN>DHK@wG-z1D*g=MNlxLtw0A++H_74P!#pvajq`6XG+ zC8IeA{Z1sjxgvQXbJXX!s5B@g_CRbfP5w@d3o@obWVdc2g=hKP0;-I#2c8}G&y~OF zpjHhT85{&eTuy_GWY899iq~3b5a2;Qc5d`YLy@&j)Nz__-X!bVFN&< zT0o-hRviX10ZnLei=w3DmYKD9YA3`l@j+zGZEs#D0K^!=%3XT~8qI}z{ab*4fPAYW zYv|i-s=QJw=LLqOXF-Hwgrt$NZ)t#F$zpS|mev!}6p+Y_0?kRF+2!QC1;XoL74$_B z7Py=N%}(mKzl6625}1c@aeFpe(ILckfK0JElPO4+40BMkK8i5E{uF z!kAVdBBDi`3wXGSz%+p3n9S}MDMyK|2D5k_9$j5 z7#=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