root/tags/rel0_59/t/11_utils.t

Revision 958, 1.9 kB (checked in by earle, 22 months ago)

Add detailed DBD::SQLite error reporting to a couple of places where it was missing.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1use strict;
2use Wiki::Toolkit::Setup::SQLite;
3use OpenGuides::Config;
4use OpenGuides::Utils;
5use Test::More tests => 8;
6
7eval { my $wiki = OpenGuides::Utils->make_wiki_object; };
8ok( $@, "->make_wiki_object croaks if no config param supplied" );
9
10eval { my $wiki = OpenGuides::Utils->make_wiki_object( config => "foo" ); };
11ok( $@, "...and if config param isn't an OpenGuides::Config object" );
12
13eval {
14    my $wiki = OpenGuides::Utils->make_wiki_object(
15        config => OpenGuides::Config->new( file => 'fake' )
16    );
17};
18
19like( $@, qr/File 'fake' does not exist/, '...and Config::Tiny errors are reported');
20
21my $have_sqlite = 1;
22my $sqlite_error;
23
24eval { require DBD::SQLite; };
25if ( $@ ) {
26    ($sqlite_error) = $@ =~ /^(.*?)\n/;
27    $have_sqlite = 0;
28}
29
30SKIP: {
31    skip "DBD::SQLite could not be used - no database to test with. ($sqlite_error)", 5
32      unless $have_sqlite;
33
34    # Clear out the database from any previous runs.
35    unlink "t/node.db";
36    unlink <t/indexes/*>;
37    Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
38
39    my $config = OpenGuides::Config->new(
40           vars => {
41                     dbtype             => "sqlite",
42                     dbname             => "t/node.db",
43                     indexing_directory => "t/indexes",
44                     script_url         => "",
45                     script_name        => "",
46                   }
47    );
48
49    eval { require Wiki::Toolkit::Search::Plucene; };
50    if ( $@ ) { $config->use_plucene ( 0 ) };
51
52    my $wiki = eval {
53        OpenGuides::Utils->make_wiki_object( config => $config );
54    };
55    is( $@, "",
56        "...but not with an OpenGuides::Config object with suitable data" );
57    isa_ok( $wiki, "Wiki::Toolkit" );
58
59    ok( $wiki->store,      "...and store defined" );
60    ok( $wiki->search_obj, "...and search defined" );
61    ok( $wiki->formatter,  "...and formatter defined" );
62}
Note: See TracBrowser for help on using the browser.