App-Fetchware

 view release on metacpan or  search on metacpan

t/App-FetchwareX-HTMLPageSync.t  view on Meta::CPAN

            re(qr/\.(tar\.(gz|bz2|xz)|(tgz|tbz2|txz))$/)
        ),
        'checked lookup()s return value for acceptable values again.'
    );

    download_links_callback sub {
        my @download_urls = @_;

        my @filtered_urls;
        for my $link (@download_urls) {
            # Strip off HTML::Element crap.
            $link = $link->attr('href');
            # Keep links that are absolute.
            # And make change relative links to absolute.
            if ($link !~ m!^(ftp|http|file)://!) {
                push @filtered_urls, config('html_page_url') . '/' . $link;
            }
        }

        # Return the filtered urls not the provided unfiltered @download_urls.
        return @filtered_urls;
    };

    my $abs_urls = lookup();

    cmp_deeply(
        $abs_urls,
        array_each(
            re(qr!^(ftp|http|file)://!)
        ),
        'checked lookup()s return value for acceptable values yet again.'
    );
};

# Created here so it can be shared with install()'s subtest.
my $download_file_paths;
subtest 'test HTMLPageSync download()' => sub {
    skip_all_unless_release_testing();


    # FETCHWARE_HTTP_DOWNLOAD_URL is manually updated will break whenever a new
    # version of Apache 2.2 comes out.
    # download() wants an array ref.
    $download_file_paths = download($temp_dir,
        [ $ENV{FETCHWARE_HTTP_DOWNLOAD_URL} ]);
    note("DFP");
    note explain $download_file_paths;

    ok(@$download_file_paths == 1,
        'checked download() correct number of files');

    is($download_file_paths->[0],
        file($ENV{FETCHWARE_HTTP_DOWNLOAD_URL})->basename(),
        'checked download() success.');

    ok(-e $download_file_paths->[0],
        'checked download()ed file existence');
};


subtest 'test HTMLPageSync verify()' => sub {
    is(verify('dummy', 'args'), undef, 'checked verify() success.');
};


subtest 'test HTMLPageSync unarchive()' => sub {
    is(unarchive(), undef, 'checked unarchive() success.');
};

subtest 'test HTMLPageSync build()' => sub {
    is(verify('dummy arg'), undef, 'checked build() success.');
};


subtest 'test HTMLPageSync install()' => sub {
    skip_all_unless_release_testing();

    ok(install($download_file_paths),
        'checked install() success');

    # install() needs an array reference.
    eval_ok(sub { install([ "file-that-doesn-t-exist-$$" ])},
        qr/App-FetchwareX-HTMLPageSync: run-time error. Fetchware failed to copy the file \[/,
        'checked install exception');
};


subtest 'test HTMLPageSync uninstall()' => sub {
    skip_all_unless_release_testing();

    # Will delete destination_directory, but the destination_directory is a
    # tempdir(), so it will be delete anyway.
    # Just ignore the warning File::Temp prints, because I deleted its tempdir()
    # instead of it doing it itself.
    ok(uninstall(cwd()),
        'checked uninstall() success');
    ok(! -e $dest_dir,
        'checked uninstall() tempdir removal');


    # Test uninstall()s exceptions.
    eval_ok(sub {uninstall("$$-@{[int(rand(383889))]}")},
        qr/App-FetchwareX-HTMLPageSync: Failed to uninstall the specified package and specifically/,
        'checked uninstall() $build_path exception');
};


subtest 'test uninstall() keep_destination_directory' => sub {
    skip_all_unless_release_testing();

    # Create another tempdir, because the previous uninstall() deleted it.
    my $tempdir = tempdir("fetchware-$$-XXXXXXXXXX", TMPDIR => 1, CLEANUP => 1);
    ok(-e $tempdir,
        'checked lookup() temporary destination directory creation');
    # Use new destination_directory.
    config_replace(destination_directory => $tempdir);

    # Install HTMLPageSync again to test keep_destination_directory.
    my $wallpaper_urls = lookup();
note explain $wallpaper_urls;
debug_CONFIG();
    cmp_deeply(
        $wallpaper_urls,
        array_each(any(
            re(qr/Announcement2.\d.(html|txt)/),
            re(qr/CHANGES_2\.\d(\.\d+)?/),
            re(qr/CURRENT(-|_)IS(-|_)\d\.\d+?\.\d+/),
            re(qr/
                HEADER.html
                |
                KEYS



( run in 0.496 second using v1.01-cache-2.11-cpan-39bf76dae61 )