Changeset 924


Ignore:
Timestamp:
Mar 10, 2007, 3:01:09 PM (14 years ago)
Author:
kake
Message:

If we haven't got DBD::SQLite, skip all tests from the start, rather than using a big SKIP block and hardcoding the number of tests in twice.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/t/74_ping_plugin.t

    r878 r924  
    55use Test::More;
    66
    7 plan tests => ( 9 );
     7eval { require DBD::SQLite; };
     8if ( $@ ) {
     9  plan skip_all => "DBD::SQLite not installed - no database to test with";
     10} else {
     11  plan tests => 9;
     12}
    813
    9 eval { require DBD::SQLite; };
    10 my $have_sqlite = $@ ? 0 : 1;
     14Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
     15my $config = OpenGuides::Config->new(
     16    vars => {
     17                dbtype             => "sqlite",
     18                dbname             => "t/node.db",
     19                indexing_directory => "t/indexes",
     20                script_url         => "http://wiki.example.com/",
     21                script_name        => "mywiki.cgi",
     22                site_name          => "Wiki::Toolkit Test Site",
     23                default_city       => "London",
     24                default_country    => "United Kingdom",
     25                ping_services      => ""
     26            }
     27);
     28my $guide = OpenGuides->new( config => $config );
    1129
    12 SKIP: {
    13     skip "DBD::SQLite not installed - no database to test with", 9
    14         unless $have_sqlite;
     30ok($guide, "Made the guide OK");
    1531
    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_url         => "http://wiki.example.com/",
    23                     script_name        => "mywiki.cgi",
    24                     site_name          => "Wiki::Toolkit Test Site",
    25                     default_city       => "London",
    26                     default_country    => "United Kingdom",
    27                     ping_services      => ""
    28                 }
    29     );
    30     my $guide = OpenGuides->new( config => $config );
    31 
    32     ok($guide, "Made the guide OK");
    33 
    34     # Check for the plugin
    35     my @plugins = @{ $guide->wiki->{_registered_plugins} };
    36     is( scalar @plugins, 2, "Two plugins to start" );
     32# Check for the plugin
     33my @plugins = @{ $guide->wiki->{_registered_plugins} };
     34is( scalar @plugins, 2, "Two plugins to start" );
    3735
    3836
    39     # Now with the plugin
    40     $config = OpenGuides::Config->new(
    41         vars => {
    42                     dbtype             => "sqlite",
    43                     dbname             => "t/node.db",
    44                     indexing_directory => "t/indexes",
    45                     script_url         => "http://wiki.example.com/",
    46                     script_name        => "mywiki.cgi",
    47                     site_name          => "Wiki::Toolkit Test Site",
    48                     default_city       => "London",
    49                     default_country    => "United Kingdom",
    50                     ping_services      => "pingerati,geourl,FOOOO"
    51                 }
    52     );
    53     $guide = OpenGuides->new( config => $config );
     37# Now with the plugin
     38$config = OpenGuides::Config->new(
     39    vars => {
     40                dbtype             => "sqlite",
     41                dbname             => "t/node.db",
     42                indexing_directory => "t/indexes",
     43                script_url         => "http://wiki.example.com/",
     44                script_name        => "mywiki.cgi",
     45                site_name          => "Wiki::Toolkit Test Site",
     46                default_city       => "London",
     47                default_country    => "United Kingdom",
     48                ping_services      => "pingerati,geourl,FOOOO"
     49            }
     50);
     51$guide = OpenGuides->new( config => $config );
    5452
    55     ok($guide, "Made the guide OK");
     53ok($guide, "Made the guide OK");
    5654
    57     @plugins = @{ $guide->wiki->{_registered_plugins} };
    58     is( scalar @plugins, 3, "Has plugin now" );
    59     ok( $plugins[2]->isa( "Wiki::Toolkit::Plugin" ), "Right plugin" );
    60     ok( $plugins[2]->isa( "Wiki::Toolkit::Plugin::Ping" ), "Right plugin" );
     55@plugins = @{ $guide->wiki->{_registered_plugins} };
     56is( scalar @plugins, 3, "Has plugin now" );
     57ok( $plugins[2]->isa( "Wiki::Toolkit::Plugin" ), "Right plugin" );
     58ok( $plugins[2]->isa( "Wiki::Toolkit::Plugin::Ping" ), "Right plugin" );
    6159
    62     # Check it has the right services registered
    63     my %services = $plugins[2]->services;
    64     my @snames = sort keys %services;
    65     is( scalar @snames, 2, "Has 2 services as expected" );
    66     is( $snames[0], "geourl", "Right service" );
    67     is( $snames[1], "pingerati", "Right service" );
    68 }
     60# Check it has the right services registered
     61my %services = $plugins[2]->services;
     62my @snames = sort keys %services;
     63is( scalar @snames, 2, "Has 2 services as expected" );
     64is( $snames[0], "geourl", "Right service" );
     65is( $snames[1], "pingerati", "Right service" );
     66
Note: See TracChangeset for help on using the changeset viewer.