CPAN-Testers-WWW-Statistics
view release on metacpan or search on metacpan
t/56writes.t view on Meta::CPAN
#!perl
use strict;
use warnings;
$|=1;
my $CHECK_DOMAIN = 'www.google.com';
# NOTE about t/56writes.t & t/expected.zip...
#
# If the write tests fail, due to any change a new expected.zip file is
# required. In order to regenerate the archive enter the following
# commands:
#
# $> prove -Ilib t/05setup_db-*.t
# $> perl -Ilib t/56writes.t --update-archive
#
# This will assume that any failing tests are actually correct, and
# create a new zip file t/expected-NEW.zip. To commit it, just enter:
#
# $> mv t/expected-NEW.zip t/expected.zip
my $UPDATE_ARCHIVE = ($ARGV[0] && $ARGV[0] eq '--update-archive') ? 1 : 0;
use Archive::Zip;
use Archive::Extract;
use File::Basename;
use File::Copy;
use File::Path;
use File::Slurp qw( slurp );
use File::Spec;
use Sort::Versions;
use Test::Differences;
use Test::More;
use lib 't';
use CTWS_Testing;
if(CTWS_Testing::has_environment()) { plan tests => 418; }
else { plan skip_all => "Environment not configured"; }
ok( my $obj = CTWS_Testing::getObj(), "got object" );
ok( CTWS_Testing::cleanDir($obj), 'directory removed' );
my $dirname = dirname($obj->mainstore);
unlink($dirname) if($dirname && -d $dirname && $dirname !~ /^\.$/);
my $rc;
my @files;
my @expectedFiles;
my $expectedDir;
my $EXPECTEDPATH = File::Spec->catfile( 't', '_EXPECTED' );
my $zip = File::Spec->catfile('t','expected.zip');
if(-f $zip) {
my $ae = Archive::Extract->new( archive => $zip );
ok( $ae->extract(to => $EXPECTEDPATH), 'extracted expected files' );
} else {
ok(0);
}
#---------------------------------------
# Tests for creating pages
my $page = CTWS_Testing::getPages();
my $dir = $obj->directory();
# copy templates directory
# .. as updates-index.html and updates-all.html are created dynamically
# we create blank version in this test version of the directory
my $SOURCE = $obj->templates();
my $TARGET = File::Spec->catfile( 't', '_TEMPLATES' );
my @source = CTWS_Testing::listFiles( $SOURCE );
for my $f (@source) {
my $source = File::Spec->catfile( $SOURCE, $f );
my $target = File::Spec->catfile( $TARGET, $f );
mkpath( dirname($target) );
copy( $source, $target ) if(-f $source);
}
my $images = File::Spec->catfile( $TARGET, 'images' );
rmtree($images);
$obj->templates($TARGET);
#my ($stats,$fails,$pass,$counts,$dists,$index,$versions) = $page->_build_stats();
## BUILD BASICS METHODS
$obj->directory($dir . '/_write_basics'),
$page->_write_basics();
check_dir_contents(
"[_write_basics]",
$obj->directory,
File::Spec->catfile($EXPECTEDPATH,'56writes._write_basics'),
);
ok( CTWS_Testing::cleanDir($obj), 'directory cleaned' );
( run in 0.801 second using v1.01-cache-2.11-cpan-6aa56a78535 )