Changeset 956 for trunk/t/54_redirect.t


Ignore:
Timestamp:
Mar 20, 2007, 4:47:05 PM (15 years ago)
Author:
Earle Martin
Message:

Complete transition to using skip_all (remove old SKIP blocks).
More verbose reporting for error "require"ing DBD::SQLite.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/t/54_redirect.t

    r949 r956  
    77eval { require DBD::SQLite; };
    88
    9 if ($@) {
    10     plan skip_all => "DBD::SQLite not installed - no database to test with";
    11 } else {
    12     plan tests => 2;
     9if ( $@ ) {
     10    my ($error) = $@ =~ /^(.*?)\n/;
     11    plan skip_all => "DBD::SQLite could not be used - no database to test with ($error)";
    1312}
    1413
    15 SKIP: {
    16     Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
    17     my $config = OpenGuides::Config->new(
    18            vars => {
    19                      dbtype             => "sqlite",
    20                      dbname             => "t/node.db",
    21                      indexing_directory => "t/indexes",
    22                      script_name        => "wiki.cgi",
    23                      script_url         => "http://example.com/",
    24                      site_name          => "Test Site",
    25                      template_path      => "./templates",
    26                    }
    27     );
    28     eval { require Wiki::Toolkit::Search::Plucene; };
    29     if ( $@ ) { $config->use_plucene ( 0 ) };
    30            
    31     my $guide = OpenGuides->new( config => $config );
    32     my $wiki = $guide->wiki;
     14plan tests => 2;
    3315
    34     # Clear out the database from any previous runs.
    35     foreach my $del_node ( $wiki->list_all_nodes ) {
    36         $wiki->delete_node( $del_node ) or die "Can't delete $del_node";
    37     }
     16Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
     17my $config = OpenGuides::Config->new(
     18       vars => {
     19                 dbtype             => "sqlite",
     20                 dbname             => "t/node.db",
     21                 indexing_directory => "t/indexes",
     22                 script_name        => "wiki.cgi",
     23                 script_url         => "http://example.com/",
     24                 site_name          => "Test Site",
     25                 template_path      => "./templates",
     26               }
     27);
     28eval { require Wiki::Toolkit::Search::Plucene; };
     29if ( $@ ) { $config->use_plucene ( 0 ) };
     30       
     31my $guide = OpenGuides->new( config => $config );
     32my $wiki = $guide->wiki;
    3833
    39     $wiki->write_node( "Test Page", "#REDIRECT [[Test Page 2]]" )
    40       or die "Can't write node";
    41     $wiki->write_node( "Test Page 2", "foo" )
    42       or die "Can't write node";
    43     my $output = eval {
    44         $guide->display_node( id => "Test Page", return_output => 1 );
    45     };
    46     is( $@, "", "->display_node doesn't die when page is a redirect" );
     34# Clear out the database from any previous runs.
     35foreach my $del_node ( $wiki->list_all_nodes ) {
     36    $wiki->delete_node( $del_node ) or die "Can't delete $del_node";
     37}
    4738
    48     # Old versions of CGI.pm mistakenly print location: instead of Location:
    49     like( $output,
    50           qr/[lL]ocation: http:\/\/example.com\/wiki.cgi\?id=Test_Page_2\;oldid=Test_Page/,
    51           "...and redirects to the right place" );
    52 }
     39$wiki->write_node( "Test Page", "#REDIRECT [[Test Page 2]]" )
     40  or die "Can't write node";
     41$wiki->write_node( "Test Page 2", "foo" )
     42  or die "Can't write node";
     43my $output = eval {
     44    $guide->display_node( id => "Test Page", return_output => 1 );
     45};
     46is( $@, "", "->display_node doesn't die when page is a redirect" );
     47
     48# Old versions of CGI.pm mistakenly print location: instead of Location:
     49like( $output,
     50      qr/[lL]ocation: http:\/\/example.com\/wiki.cgi\?id=Test_Page_2\;oldid=Test_Page/,
     51      "...and redirects to the right place" );
Note: See TracChangeset for help on using the changeset viewer.