App-Fetchware

 view release on metacpan or  search on metacpan

t/App-Fetchware-lookup.t  view on Meta::CPAN

};


subtest 'test lookup_by_versionstring()' => sub {
    __clear_CONFIG();

    cmp_deeply(lookup_by_versionstring(test_filename_listing('no current')),
        eval(expected_filename_listing()),
        'check lookup_by_versionstring() success.');

    # Also test for when lower numbered versionstrings sort higher using the
    # previous buggy implementatino that just concatenated them resulting in
    # version strings such as 9.0.13 (9013) being "technically" higher than
    # 9.3.5 (935), but it really should be the other way around, because the 3
    # is bigger than the 0.
    my $more_digits_than_higher_one = [
        ['v9.0.13', '51651653615161'],
        ['v9.3.5', '645784816181814'],
        ['v8.0.32', '48465843434848'],
        ['v8.4.6', '648468484354848'],
        ['v7.0.53', '45454675374874'],
        ['v7.0.42', '32151651145545'],
        ['v7.0.41', '25454546348484'],
        ['v7.6.12', '75434843484844'],
        ['v6',      '17777777777777'],
        ['v6.2.9',  '18888888888888'],
        ['v6.3',    '19999999999999'],
        ['v5.0',     '1777777777777'],
        ['v5.2.9',   '1888888888888'],
        ['v5.3',     '1999999999999'],
    ];

    my $expected_more_digits_than_higher_one = [
        ['v9.3.5', '645784816181814'],
        ['v9.0.13', '51651653615161'],
        ['v8.4.6', '648468484354848'],
        ['v8.0.32', '48465843434848'],
        ['v7.6.12', '75434843484844'],
        ['v7.0.53', '45454675374874'],
        ['v7.0.42', '32151651145545'],
        ['v7.0.41', '25454546348484'],
        # Test for unequal # of version numbers too.
        ['v6.3',    '19999999999999'],
        ['v6.2.9',  '18888888888888'],
        ['v6',      '17777777777777'],
        # Test the same thing as above, but with a .0 on the end.
        ['v5.3',     '1999999999999'],
        ['v5.2.9',   '1888888888888'],
        ['v5.0',     '1777777777777'],
    ];

    my $sorted_file_listing =
        lookup_by_versionstring($more_digits_than_higher_one);

    is_deeply($sorted_file_listing, $expected_more_digits_than_higher_one,
        'checked lookup_by_versionstring() unequal length bug fix.');

    # Also, test for duplicate version numbers--when two files have the same
    # version string. Note: real-world mirrors are not going to have duplicate
    # versions of the same program, but they might have multiple versions of the
    # same version of the same program. For example apache has a unix source
    # download, but also one for Windows, and one for dependencies.
    # NOTE: The "timestamp" info for each pair of duplicate version numbers
    # (for example, '111111111111111') must be the same, because some versions
    # of perl use a quicksort sort algorithm that does not preserve the original
    # order of equivelent entries. So, the order could change, which will break
    # the  simple is_deeply() test.
    my $same_version_number = [
        ['v4.0.0', '444444444444444'],
        ['v2.0.0', '222222222222222'],
        ['v1.0.0', '111111111111111'],
        ['v3.0.0', '333333333333333'],
        ['v2.0.0', '222222222222222'],
        ['v1.0.0', '111111111111111'],
        ['v3.0.0', '333333333333333'],
        ['v4.0.0', '444444444444444'],
    ];

    my $expected_same_version_number = [
        ['v4.0.0', '444444444444444'],
        ['v4.0.0', '444444444444444'],
        ['v3.0.0', '333333333333333'],
        ['v3.0.0', '333333333333333'],
        ['v2.0.0', '222222222222222'],
        ['v2.0.0', '222222222222222'],
        ['v1.0.0', '111111111111111'],
        ['v1.0.0', '111111111111111'],
    ];

    my $sorted_file_listing2 =
        lookup_by_versionstring($same_version_number);

    is_deeply($sorted_file_listing2, $expected_same_version_number,
        'checked lookup_by_versionstring() same version number bugfix.');
}; 


subtest 'test determine_download_path()' => sub {
    skip_all_unless_release_testing();

    # Clear App::Fetchware's %CONFIG variable.
    __clear_CONFIG();

    # This must be set for lookup() to work on Apache's mirror format.
    filter 'httpd-2.2';

    # Set needed config variables.
    lookup_url "$test_lookup_url";
    # Must also specify program, mirror, and a verify method.
    program 'testin';
    mirror "$test_lookup_url";
    verify_failure_ok 'On';

    my $directory_listing = get_directory_listing();
    my $filename_listing = parse_directory_listing($directory_listing);
    
    like(determine_download_path($filename_listing),
        qr{httpd-2.2.\d+?.tar.bz2},
        'checked determine_download_path() success.');
    
    # Clear App::Fetchware's %CONFIG variable so I can test it with custom

t/App-Fetchware-lookup.t  view on Meta::CPAN

<img src="/icons/quill.gif" alt="[SIG]"> <a href="httpd-2.4.3.tar.gz.asc">httpd-2.4.3.tar.gz.asc</a>         20-Aug-2012 09:22  825   PGP signature
<hr></pre>
<h2><a name="mirrors">Download from your
    <a href="http://www.apache.org/dyn/closer.cgi/httpd/"
      >nearest mirror site!</a></a></h2>

<p>Do not download from www.apache.org.  Please use a mirror site
   to help us save apache.org bandwidth.
   <a href="http://www.apache.org/dyn/closer.cgi/httpd/">Go
   here to find your nearest mirror.</a></p>

<h2><a name="binaries">Binary Releases</a></h2>

<p>Are available in the <a href="binaries/">binaries/</a> directory.
   Every binary distribution contains an install script. See README
   for details.</p>

<h2><a name="releases">Current Releases</a></h2>

<p>For details on current releases, please see the
   <a href="http://httpd.apache.org/download.cgi">Apache HTTP
   Server Download Page</a>.</p>

<p>Note; the -win32-src.zip versions of Apache are nearly identical to the
   .tar.gz versions.  However, they offer the source files in DOS/Windows
   CR/LF text format, and include the Win32 build files.
   These -win32-src.zip files <strong>do NOT contain binaries!</strong>
   See the <a href="binaries/win32/">binaries/win32/</a>
   directory for the Windows binary distributions.</p>

<h2><a name="archive">Older Releases</a></h2>

<p>Only current, recommended releases are available on www.apache.org
   and the mirror sites.  Older releases can be obtained from the <a
   href="http://archive.apache.org/dist/httpd/">archive site</a>.</p>

<h2><a name="sig">PGP Signatures</a></h2>

<p>All of the release distribution packages have been digitally signed
   (using PGP or GPG) by the Apache Group members that constructed them.
   There will be an accompanying <SAMP><EM>distribution</EM>.asc</SAMP> file
   in the same directory as the distribution.  The PGP keys can be found
   at the MIT key repository and within this project's
   <a href="http://www.apache.org/dist/httpd/KEYS">KEYS file</a>.</p>

<p>Always use the signature files to verify the authenticity
   of the distribution, <i>e.g.</i>,</p>

<pre>
% pgpk -a KEYS
% pgpv httpd-2.2.8.tar.gz.asc
<i>or</i>,
% pgp -ka KEYS
% pgp httpd-2.2.8.tar.gz.asc
<i>or</i>,
% gpg --import KEYS
% gpg --verify httpd-2.2.8.tar.gz.asc
</pre>

<p>We offer MD5 hashes as an alternative to validate the integrity
   of the downloaded files. A unix program called <code>md5</code> or
   <code>md5sum</code> is included in many unix distributions.  It is
   also available as part of <a
   href="http://www.gnu.org/software/textutils/textutils.html">GNU
   Textutils</a>.  Windows users can get binary md5 programs from <a
   href="http://www.fourmilab.ch/md5/">here</a>, <a
   href="http://www.pc-tools.net/win32/freeware/console/">here</a>, or
   <a href="http://www.slavasoft.com/fsum/">here</a>.</p>

<h2><a name="patches">Official Patches</a></h2>

<p>When we have patches to a minor bug or two, or features which we
   haven't yet included in a new release, we will put them in the
   <A HREF="patches/">patches</A>
   subdirectory so people can get access to it before we roll another
   complete release.</p>
</body></html>
EOH
    return $html_listing;
}



( run in 2.453 seconds using v1.01-cache-2.11-cpan-64ef6c95b5d )