IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 24355


Ignore:
Timestamp:
Jun 8, 2009, 11:46:09 AM (17 years ago)
Author:
jhoblitt
Message:

make sure that atleast one db is always defined

Location:
trunk/Nebulous-Server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/lib/Nebulous/Server.pm

    r24354 r24355  
    1313use base qw( Class::Accessor::Fast );
    1414
     15use Cache::Memcached::Managed;
    1516use DBI;
    1617use Digest::SHA1 qw( sha1_hex );
     
    2728use Params::Validate qw( validate validate_pos SCALAR SCALARREF UNDEF BOOLEAN );
    2829use URI::file;
    29 use Cache::Memcached::Managed;
    3030
    3131__PACKAGE__->mk_accessors(qw( log sql config cache ));
     
    6464    $self->config($config);
    6565    $self->cache(Cache::Memcached::Managed->new($config->memcached));
     66    $log->logdie("at least one database must be defined") unless $config->n_db;
     67
    6668    # cause a db session to be started
    6769    $self->_db_for_index(0);
  • trunk/Nebulous-Server/t/02_server_setup.t

    r23932 r24355  
    1717Test::Nebulous->setup;
    1818
    19 isa_ok(Nebulous::Server->new(), "Nebulous::Server");
    20 
    21 Test::Nebulous->setup;
    22 
    2319# ->new()
    24 {
    25     my $neb = Nebulous::Server->new( trace => 'off' );
    26 
    27     ok($neb, "set log level");
    28 }
    29 
    30 Test::Nebulous->setup;
    3120
    3221{
    3322    my $neb = Nebulous::Server->new(
    34         dsn         => "DBI:mysql:database=foobar:host=localhost",
    35         dbuser      => "baz",
    36         dbpasswd    =>"boo",
     23        dsn         => $NEB_DB,
     24        dbuser      => $NEB_USER,
     25        dbpasswd    => $NEB_PASS,
    3726    );
    3827
     
    4231Test::Nebulous->setup;
    4332
     33{
     34    my $neb = Nebulous::Server->new(
     35        dsn         => $NEB_DB,
     36        dbuser      => $NEB_USER,
     37        dbpasswd    => $NEB_PASS,
     38        trace       => 'off',
     39    );
     40
     41    ok($neb, "set log level");
     42}
     43
     44Test::Nebulous->setup;
     45
    4446# add dbs after ->new()
    4547{
    46     my $neb = Nebulous::Server->new;
     48    my $config = Nebulous::Server::Config->new;
    4749
    48     ok($neb->config->add_db(
     50    ok($config->add_db(
    4951        dbindex    => 0,
    50         dsn         => "DBI:mysql:database=foobar:host=localhost",
    51         dbuser      => "baz",
    52         dbpasswd    =>"boo",
     52        dsn         => $NEB_DB,
     53        dbuser      => $NEB_USER,
     54        dbpasswd    => $NEB_PASS,
    5355    ), "add db");
    5456   
    55     ok($neb->config->add_db(
     57    ok($config->add_db(
    5658        dbindex    => 1,
    57         dsn         => "DBI:mysql:database=foobar:host=localhost",
    58         dbuser      => "baz",
    59         dbpasswd    =>"boo",
     59        dsn         => $NEB_DB,
     60        dbuser      => $NEB_USER,
     61        dbpasswd    => $NEB_PASS,
    6062    ), "add dbs");
    6163
    62     is($neb->config->n_db, 2, "n dbs")
     64    is($config->n_db, 2, "n dbs");
     65
     66    my $neb = Nebulous::Server->new_from_config($config);
     67     
     68    isa_ok($neb, 'Nebulous::Server');
    6369}
    6470
Note: See TracChangeset for help on using the changeset viewer.