From: Chris W. <la...@us...> - 2005-02-28 01:04:12
|
Update of /cvsroot/openinteract/OpenInteract2/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32042 Modified Files: utils.pl package.t config_package.t 00_manage_create_website.t Added Files: config_bootstrap.t Removed Files: config_base.t Log Message: OIN-137: testing updates as a result of moving package.conf -> package.ini (also with eliminating doc/, but more of that in a bit...) --- NEW FILE: config_bootstrap.t --- # -*-perl-*- # $Id: config_bootstrap.t,v 1.1 2005/02/28 01:03:59 lachoy Exp $ use strict; use lib 't/'; require 'utils.pl'; use File::Copy qw( cp ); use File::Spec::Functions qw( catfile ); use OpenInteract2::Constants qw( BOOTSTRAP_CONF_DIR BOOTSTRAP_CONF_FILE ); use Test::More tests => 31; require_ok( 'OpenInteract2::Config::Bootstrap' ); initialize_context(); { my $dir = '/path/to/mysite'; my $filename = OpenInteract2::Config::Bootstrap ->create_filename( $dir ); is( $filename, catfile( $dir, 'bootstrap.ini' ), 'Create default filename' ); my $web_filename = OpenInteract2::Config::Bootstrap ->create_website_filename( $dir ); is( $web_filename, catfile( $dir, 'conf', 'bootstrap.ini' ), 'Create default website filename' ); } my $website_dir = get_test_site_dir(); my $config_type = 'ini'; my $config_class = 'OpenInteract2::Config::IniFile'; my $config_dir = 'conf'; my $config_file = 'server.ini'; my $package_dir = 'pkg'; my $temp_lib_dir = 'tmplib'; my $existing_file = catfile( $website_dir, 'conf', 'bootstrap.ini' ); cp( $existing_file, "$existing_file.bak" ) || die "Cannot rename '$existing_file' to '$existing_file.bak': $!"; unlink( $existing_file ); # Create a new config { my $c = eval { OpenInteract2::Config::Bootstrap->new() }; ok( ! $@, 'Created empty object' ) || diag "Error: $@"; is( $c->website_dir( $website_dir ), $website_dir, 'Website dir set' ); is( $c->config_type( $config_type ), $config_type, 'Config type set' ); is( $c->config_class( $config_class ), $config_class, 'Config class set' ); is( $c->config_dir( $config_dir ), $config_dir, 'Config subdir set' ); is( $c->config_file( $config_file ), $config_file, 'Config filename set' ); is( $c->package_dir( $package_dir ), $package_dir, 'Package dir set' ); is( $c->temp_lib_dir( $temp_lib_dir ), $temp_lib_dir, 'Temp library dir set' ); my $wrote_file = eval { $c->save_config() }; ok( ! $@, 'Config file write to default execute' ) || diag "Error: $@"; is( $wrote_file, $existing_file, 'Correct filename for saved config' ); ok( -f $wrote_file, 'File written exists' ); # Remove a required field and try to save again... $c->config_dir( '' ); eval { $c->save_config() }; like( "$@", qr/^Cannot save bootstrap config: the following fields/, 'Expected error when required field removed' ); $c->config_dir( $config_dir ); unlink( $wrote_file ); rename( "$existing_file.bak", $existing_file ); my $temp_wrote_file = get_use_file( 'bootstrap.ini', 'name' ); $c->filename( $temp_wrote_file ); my $wrote_file_spec = eval { $c->save_config() }; ok( ! $@, 'Config file write to specified execute' ) || diag "Error: $@"; is( $wrote_file_spec, $temp_wrote_file, 'Correct filename for saved config' ); ok( -f $wrote_file_spec, 'File written exists' ); unlink( $temp_wrote_file ); } # Read an existing config using the 'website_dir' method { my $c = eval { OpenInteract2::Config::Bootstrap->new({ website_dir => $website_dir }) }; ok( ! $@, 'Object created from website dir' ) || diag "Error: $@"; is( $c->website_dir(), $website_dir, 'Website dir read' ); is( $c->config_type(), $config_type, 'Config type read' ); is( $c->config_class(), $config_class, 'Config class read' ); is( $c->config_dir(), $config_dir, 'Config dir read' ); is( $c->config_file(), $config_file, 'Config file read' ); is( $c->package_dir(), $package_dir, 'Package dir read' ); is( $c->temp_lib_dir(), $temp_lib_dir, 'Temporary library dir read' ); is( $c->filename(), $existing_file, 'Filename set' ); } # Read an existing config using the 'filename' method, then save it to # a separate file { my $c = eval { OpenInteract2::Config::Bootstrap->new({ filename => $existing_file }); }; ok( ! $@, 'Object created from filename' ) || diag "Error: $@"; is( $c->website_dir(), $website_dir, 'Website dir set at initialization' ); my $new_file = $existing_file; $new_file =~ s/\.ini$/-alt.ini/; $c->filename( $new_file ); my $wrote_file = eval { $c->save_config }; ok ( ! $@, 'Alternate config file written' ); is( $wrote_file, $new_file, 'Correct alternate filename saved' ); unlink( $new_file ); } Index: utils.pl =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/t/utils.pl,v retrieving revision 1.93 retrieving revision 1.94 diff -C2 -d -r1.93 -r1.94 *** utils.pl 26 Feb 2005 05:52:53 -0000 1.93 --- utils.pl 28 Feb 2005 01:03:59 -0000 1.94 *************** *** 45,64 **** sub main::get_package_versions { return ( ! base => '2.12', ! base_box => '2.17', ! base_error => '3.00', ! base_group => '2.16', ! base_page => '2.28', ! base_security => '2.18', ! base_template => '3.15', ! base_theme => '2.10', ! base_user => '2.37', ! comments => '1.19', ! full_text => '2.58', ! lookup => '2.07', ! news => '2.20', ! object_activity => '2.11', ! system_doc => '2.08', ! whats_new => '2.10', ); } --- 45,64 ---- sub main::get_package_versions { return ( ! base => '2.13', ! base_box => '2.18', ! base_error => '3.01', ! base_group => '2.17', ! base_page => '2.29', ! base_security => '2.19', ! base_template => '3.16', ! base_theme => '2.11', ! base_user => '2.38', ! comments => '1.20', ! full_text => '2.59', ! lookup => '2.08', ! news => '2.21', ! object_activity => '2.12', ! system_doc => '2.09', ! whats_new => '2.11', ); } *************** *** 131,144 **** } - # This should be the parent of the test directory... - - sub main::get_source_dir { - my $test_dir = get_test_dir(); - my @dirs = splitdir( $test_dir ); - pop @dirs; - return catdir( @dirs ); - } - - sub main::rmtree { return File::Path::rmtree( [ @_ ] ); --- 131,134 ---- *************** *** 209,215 **** sub main::install_website { - my $source_dir = get_source_dir(); my $website_dir = get_test_site_dir(); ! my $is_recent = _is_recent_website( $website_dir ); initialize_website_libraries(); --- 199,204 ---- sub main::install_website { my $website_dir = get_test_site_dir(); ! my $is_recent = _is_recent_website( $website_dir ); initialize_website_libraries(); *************** *** 236,242 **** # let any errors bubble up ! my $manage = OpenInteract2::Manage->new( 'create_website', ! { website_dir => $website_dir, ! source_dir => $source_dir } ); LOG()->debug( "Created management task for creating website" ); $manage->execute; --- 225,231 ---- # let any errors bubble up ! my $manage = OpenInteract2::Manage->new( ! 'create_website', { website_dir => $website_dir } ! ); LOG()->debug( "Created management task for creating website" ); $manage->execute; *************** *** 279,283 **** package => [ 'SYSTEM' ], })->execute(); ! OpenInteract2::Setup->run_setup_for( 'initialize spops' ); } --- 268,272 ---- package => [ 'SYSTEM' ], })->execute(); ! #OpenInteract2::Setup->run_setup_for( 'read spops config' ); } *************** *** 300,305 **** install_website(); unless ( CTX ) { ! OpenInteract2::Context->create( ! { website_dir => get_test_site_dir() }); } return CTX; --- 289,295 ---- install_website(); unless ( CTX ) { ! OpenInteract2::Context->create({ ! website_dir => get_test_site_dir() ! }); } return CTX; Index: package.t =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/t/package.t,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** package.t 27 Sep 2004 20:12:02 -0000 1.16 --- package.t 28 Feb 2005 01:03:59 -0000 1.17 *************** *** 8,12 **** use File::Copy qw( cp ); use File::Spec::Functions qw( catdir catfile ); ! use Test::More tests => 121; require_ok( 'OpenInteract2::Package' ); --- 8,12 ---- use File::Copy qw( cp ); use File::Spec::Functions qw( catdir catfile ); ! use Test::More tests => 117; require_ok( 'OpenInteract2::Package' ); *************** *** 91,97 **** # that the export fails ! my $bad_config_file = get_use_file( 'test_package_bad.conf', 'name' ); ! my $bad_config = OpenInteract2::Config::Package->new( ! { filename => $bad_config_file }); my $good_config = $d_package->config; $d_package->config( $bad_config ); --- 91,98 ---- # that the export fails ! my $bad_config_file = get_use_file( 'test_package_bad.ini', 'name' ); ! my $bad_config = OpenInteract2::Config::Package->new({ ! filename => $bad_config_file ! }); my $good_config = $d_package->config; $d_package->config( $bad_config ); *************** *** 317,330 **** { - my $source_dir = get_source_dir(); - my %skel_args = ( source_dir => $source_dir ); - # Expect this to die since we're not giving a name ! eval { OpenInteract2::Package->create_skeleton( { %skel_args } ) }; like( $@, qr/^Must pass in package name/, "Expected error with no name to create package" ); ! eval { OpenInteract2::Package->create_skeleton({ %skel_args, name => ' ' }) }; like( $@, qr/Name must not be blank/, "Expected error with blank name to create package" ); --- 318,328 ---- { # Expect this to die since we're not giving a name ! eval { OpenInteract2::Package->create_skeleton() }; like( $@, qr/^Must pass in package name/, "Expected error with no name to create package" ); ! eval { OpenInteract2::Package->create_skeleton({ name => ' ' }) }; like( $@, qr/Name must not be blank/, "Expected error with blank name to create package" ); *************** *** 332,345 **** # Expect these to die since we're giving a bad name (like Bon Jovi, arg) ! eval { OpenInteract2::Package->create_skeleton({ %skel_args, name => 'my package' }) }; like( $@, qr/Name must not have spaces/, "Expected error with spaces in name to create package" ); ! eval { OpenInteract2::Package->create_skeleton({ %skel_args, name => 'my-package' }) }; like( $@, qr/Name must not have dashes/, "Expected error with dashes in name to create package" ); ! eval { OpenInteract2::Package->create_skeleton({ %skel_args, name => '2mypackage' }) }; like( $@, qr/Name must not start with a number/, "Expected error with leading number in name to create package" ); ! eval { OpenInteract2::Package->create_skeleton({ %skel_args, name => 'mypackagenum#' }) }; like( $@, qr/Name must not have non-word characters/, "Expected error with non-word chars in name to create package" ); --- 330,343 ---- # Expect these to die since we're giving a bad name (like Bon Jovi, arg) ! eval { OpenInteract2::Package->create_skeleton({ name => 'my package' }) }; like( $@, qr/Name must not have spaces/, "Expected error with spaces in name to create package" ); ! eval { OpenInteract2::Package->create_skeleton({ name => 'my-package' }) }; like( $@, qr/Name must not have dashes/, "Expected error with dashes in name to create package" ); ! eval { OpenInteract2::Package->create_skeleton({ name => '2mypackage' }) }; like( $@, qr/Name must not start with a number/, "Expected error with leading number in name to create package" ); ! eval { OpenInteract2::Package->create_skeleton({ name => 'mypackagenum#' }) }; like( $@, qr/Name must not have non-word characters/, "Expected error with non-word chars in name to create package" ); *************** *** 353,362 **** my $skel_pkg = eval { ! OpenInteract2::Package->create_skeleton({ name => 'foo', ! source_dir => $source_dir }) }; ok( ! $@, 'Create skeleton superficially succeeded' ) || diag "Error: $@"; diag( "Error creating skeleton: $@" ) if ( $@ ); ! my @dirs = ( 'conf', 'data', 'doc', 'script', 'struct', 'template', 'html', [ 'html', 'images' ], 'OpenInteract2', ['OpenInteract2', 'Action' ], --- 351,359 ---- my $skel_pkg = eval { ! OpenInteract2::Package->create_skeleton({ name => 'foo' }) }; ok( ! $@, 'Create skeleton superficially succeeded' ) || diag "Error: $@"; diag( "Error creating skeleton: $@" ) if ( $@ ); ! my @dirs = ( 'conf', 'data', 'script', 'struct', 'template', 'html', [ 'html', 'images' ], 'OpenInteract2', ['OpenInteract2', 'Action' ], *************** *** 372,377 **** 'MANIFEST', 'MANIFEST.SKIP', ! 'package.conf', ! [ 'doc', 'foo.pod' ], [ 'OpenInteract2', 'SQLInstall', 'Foo.pm' ], [ 'OpenInteract2', 'Action', 'Foo.pm' ], --- 369,373 ---- 'MANIFEST', 'MANIFEST.SKIP', ! 'package.ini', [ 'OpenInteract2', 'SQLInstall', 'Foo.pm' ], [ 'OpenInteract2', 'Action', 'Foo.pm' ], *************** *** 393,397 **** # Expect this to die since the directory will already exist ! eval { OpenInteract2::Package->create_skeleton({ %skel_args, name => 'foo' }) }; like( $@, qr/^Cannot create package destination directory.*already exists$/, "Expected error since destionation directory exists" ); --- 389,393 ---- # Expect this to die since the directory will already exist ! eval { OpenInteract2::Package->create_skeleton({ name => 'foo' }) }; like( $@, qr/^Cannot create package destination directory.*already exists$/, "Expected error since destionation directory exists" ); *************** *** 427,432 **** is( scalar @{ $actions }, 1, "Action files from package $label" ); - my $docs = $pkg->get_doc_files; - is( scalar @{ $docs }, 1, - "Doc files from package $label" ); } --- 423,425 ---- Index: config_package.t =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/t/config_package.t,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** config_package.t 8 Feb 2005 17:45:31 -0000 1.12 --- config_package.t 28 Feb 2005 01:03:59 -0000 1.13 *************** *** 15,19 **** my @action_file = qw( conf/action.ini ); my $sql_installer = 'OpenInteract2::SQLInstall::OITest'; ! my %filter = ( myfilter => 'OpenInteract2::Filter::My' ); my @config_watch = qw( OpenInteract2::MyWatcher ); my $url = 'http://www.openinteract.org/'; --- 15,19 ---- my @action_file = qw( conf/action.ini ); my $sql_installer = 'OpenInteract2::SQLInstall::OITest'; ! my %observer = ( myfilter => 'OpenInteract2::Filter::My' ); my @config_watch = qw( OpenInteract2::MyWatcher ); my $url = 'http://www.openinteract.org/'; *************** *** 57,61 **** is_deeply( $c->config_watcher( \@config_watch ), \@config_watch, 'Config watcher set' ); ! is_deeply( $c->observer( \%filter ), \%filter, 'Observer set' ); is( $c->description( $description ), $description, --- 57,61 ---- is_deeply( $c->config_watcher( \@config_watch ), \@config_watch, 'Config watcher set' ); ! is_deeply( $c->observer( \%observer ), \%observer, 'Observer set' ); is( $c->description( $description ), $description, *************** *** 81,85 **** 'Second alt result from author_emails()' ); ! my $write_file = get_use_file( 'test-write_package.conf', 'name' ); is( $c->filename( $write_file ), $write_file, 'Filename set' ); --- 81,85 ---- 'Second alt result from author_emails()' ); ! my $write_file = get_use_file( 'test-write_package.ini', 'name' ); is( $c->filename( $write_file ), $write_file, 'Filename set' ); *************** *** 95,99 **** # Now open an existing file { ! my $read_file = get_use_file( 'test_package.conf', 'name' ); my $c = eval { OpenInteract2::Config::Package->new({ filename => $read_file }) --- 95,99 ---- # Now open an existing file { ! my $read_file = get_use_file( 'test_package.ini', 'name' ); my $c = eval { OpenInteract2::Config::Package->new({ filename => $read_file }) *************** *** 119,123 **** is_deeply( $c->config_watcher, \@config_watch, 'Config watcher read' ); ! is_deeply( $c->observer, \%filter, 'Observer read' ); is( $c->description(), $description, --- 119,123 ---- is_deeply( $c->config_watcher, \@config_watch, 'Config watcher read' ); ! is_deeply( $c->observer, \%observer, 'Observer read' ); is( $c->description(), $description, Index: 00_manage_create_website.t =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/t/00_manage_create_website.t,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** 00_manage_create_website.t 22 Feb 2005 19:17:26 -0000 1.4 --- 00_manage_create_website.t 28 Feb 2005 01:03:59 -0000 1.5 *************** *** 16,26 **** my $website_dir = get_test_site_dir(); ! # Delete the testing site if it already exists ! if ( -d $website_dir ) { ! rmtree( $website_dir ); ! } ! ! my $source_dir = get_source_dir(); create_tmp_dir(); --- 16,24 ---- my $website_dir = get_test_site_dir(); + my $db_file = get_test_site_db_file(); ! # Delete the testing site and db if they already exist ! rmtree( $website_dir ) if ( -d $website_dir ); ! unlink( $db_file ) if ( -f $db_file ); create_tmp_dir(); *************** *** 29,34 **** OpenInteract2::Manage->new( 'create_website', { ! website_dir => $website_dir, ! source_dir => $source_dir, }) }; --- 27,31 ---- OpenInteract2::Manage->new( 'create_website', { ! website_dir => $website_dir }) }; *************** *** 75,79 **** is( count_files( $site_conf_dir ), 16, "Number of files in conf/" ); ! is( first_file( $site_conf_dir ), 'base.conf', "First file in conf/" ); is( last_file( $site_conf_dir ), 'startup_mp2.pl', --- 72,76 ---- is( count_files( $site_conf_dir ), 16, "Number of files in conf/" ); ! is( first_file( $site_conf_dir ), 'bootstrap.ini', "First file in conf/" ); is( last_file( $site_conf_dir ), 'startup_mp2.pl', --- config_base.t DELETED --- |