IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 12, 2008, 11:13:41 AM (18 years ago)
Author:
jhoblitt
Message:

first attempt at supporting multiple databases

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/t/02_server_setup.t

    r16281 r20965  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 02_server_setup.t,v 1.6 2008-02-02 01:51:29 jhoblitt Exp $
     5# $Id: 02_server_setup.t,v 1.7 2008-12-12 21:13:41 jhoblitt Exp $
    66
    77use strict;
    88use warnings;
    99
    10 use Test::More tests => 2;
     10use Test::More tests => 6;
    1111
    1212use lib qw( ./t ./lib );
     
    1717Test::Nebulous->setup;
    1818
    19 isa_ok(
    20     Nebulous::Server->new(
    21         dsn         => $NEB_DB,
    22         dbuser      => $NEB_USER,
    23         dbpasswd    => $NEB_PASS,
    24     ),
    25     "Nebulous::Server"
    26 );
     19isa_ok(Nebulous::Server->new(), "Nebulous::Server");
    2720
    2821Test::Nebulous->setup;
    2922
    30 eval {
    31     Nebulous::Server->new(
     23# ->new()
     24{
     25    my $neb = Nebulous::Server->new( log_level => 'off' );
     26
     27    ok($neb, "set log level");
     28}
     29
     30Test::Nebulous->setup;
     31
     32{
     33    my $neb = Nebulous::Server->new(
    3234        dsn         => "DBI:mysql:database=foobar:host=localhost",
    3335        dbuser      => "baz",
    3436        dbpasswd    =>"boo",
    3537    );
    36 };
    37 like( $@, qr/DBI connect.*? failed/, "bad dsn/user/pass" );
     38
     39    ok($neb, "set database");
     40}
     41
     42Test::Nebulous->setup;
     43
     44# add dbs after ->new()
     45{
     46    my $neb = Nebulous::Server->new;
     47
     48    ok($neb->config->add_db(
     49        dbindex    => 0,
     50        dsn         => "DBI:mysql:database=foobar:host=localhost",
     51        dbuser      => "baz",
     52        dbpasswd    =>"boo",
     53    ), "add db");
     54   
     55    ok($neb->config->add_db(
     56        dbindex    => 1,
     57        dsn         => "DBI:mysql:database=foobar:host=localhost",
     58        dbuser      => "baz",
     59        dbpasswd    =>"boo",
     60    ), "add dbs");
     61
     62    is($neb->config->n_db, 2, "n dbs")
     63}
    3864
    3965Test::Nebulous->cleanup;
Note: See TracChangeset for help on using the changeset viewer.