root/tags/rel0_58/t/11_utils.t

Revision 907, 1.8 kB (checked in by earle, 2 years ago)

Report Config::Tiny errors - closes #109. Now croaks if specified config file can't be read.

  • 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
21eval { require DBD::SQLite; };
22my $have_sqlite = $@ ? 0 : 1;
23
24SKIP: {
25    skip "DBD::SQLite not installed - no database to test with", 5
26      unless $have_sqlite;
27
28    # Clear out the database from any previous runs.
29    unlink "t/node.db";
30    unlink <t/indexes/*>;
31    Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
32
33    my $config = OpenGuides::Config->new(
34           vars => {
35                     dbtype             => "sqlite",
36                     dbname             => "t/node.db",
37                     indexing_directory => "t/indexes",
38                     script_url         => "",
39                     script_name        => "",
40                   }
41    );
42
43    eval { require Wiki::Toolkit::Search::Plucene; };
44    if ( $@ ) { $config->use_plucene ( 0 ) };
45
46    my $wiki = eval {
47        OpenGuides::Utils->make_wiki_object( config => $config );
48    };
49    is( $@, "",
50        "...but not with an OpenGuides::Config object with suitable data" );
51    isa_ok( $wiki, "Wiki::Toolkit" );
52
53    ok( $wiki->store,      "...and store defined" );
54    ok( $wiki->search_obj, "...and search defined" );
55    ok( $wiki->formatter,  "...and formatter defined" );
56}
Note: See TracBrowser for help on using the browser.