Changeset 361 for trunk/t/11_utils.t

Show
Ignore:
Timestamp:
06/07/04 21:39:35 (5 years ago)
Author:
kake
Message:

Test overhaul - no longer require database access info.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/t/11_utils.t

    r174 r361  
    11use strict; 
    22use Config::Tiny; 
    3 use Test::More tests => 9; 
    4  
    5 # Need to use a BEGIN block for the test or we get "Too late to run INIT block" 
    6 # from Class::Delegation 
    7  
    8 BEGIN { 
    9   use_ok( "OpenGuides::Utils" ); 
    10 } 
     3use OpenGuides::Utils; 
     4use Test::More tests => 7; 
    115 
    126eval { my $wiki = OpenGuides::Utils->make_wiki_object; }; 
     
    1610ok( $@, "...and if config param isn't a Config::Tiny object" ); 
    1711 
    18 my $config = Config::Tiny->read( "wiki.conf" ) 
    19     or die "Couldn't read wiki.conf"; 
    20 my $wiki = eval { OpenGuides::Utils->make_wiki_object( config => $config ); }; 
    21 is( $@, "", "...but not if a Config::Tiny object is supplied" ); 
    22 isa_ok( $wiki, "CGI::Wiki" ); 
     12eval { require DBD::SQLite; }; 
     13my $have_sqlite = $@ ? 0 : 1; 
    2314 
    24 ok( $wiki->store,      "...and store defined" ); 
    25 ok( $wiki->search_obj, "...and search defined" ); 
    26 ok( $wiki->formatter,  "...and formatter defined" ); 
     15SKIP: { 
     16    skip "DBD::SQLite not installed - no database to test with", 5 
     17      unless $have_sqlite; 
    2718 
    28 # Ensure that we take note of any defined dbhost - note that this test 
    29 # is only useful if we've defined a dbhost during perl Build.PL 
    30 is( $wiki->store->dbhost, $config->{_}->{dbhost}, "dbhost taken note of" ); 
     19    my $config = Config::Tiny->new; 
     20    $config->{_} = { 
     21                     dbtype             => "sqlite", 
     22                     dbname             => "t/node.db", 
     23                     indexing_directory => "t/indexes", 
     24                     script_url         => "", 
     25                     script_name        => "", 
     26                   }; 
     27 
     28    my $wiki = eval { 
     29        OpenGuides::Utils->make_wiki_object( config => $config ); 
     30    }; 
     31    is( $@, "", 
     32        "...but not if a Config::Tiny object with suitable data is supplied" ); 
     33    isa_ok( $wiki, "CGI::Wiki" ); 
     34 
     35    ok( $wiki->store,      "...and store defined" ); 
     36    ok( $wiki->search_obj, "...and search defined" ); 
     37    ok( $wiki->formatter,  "...and formatter defined" ); 
     38}