#!/usr/bin/perl

# Copryight (C) 2004-2005  Joshua Hoblitt
#
# $Id: 02_server_setup.t,v 1.8 2008-12-14 22:54:25 eugene Exp $

use strict;
use warnings;

use Test::More tests => 6;

use lib qw( ./t ./lib );

use Nebulous::Server;
use Test::Nebulous;

Test::Nebulous->setup;

isa_ok(Nebulous::Server->new(), "Nebulous::Server");

Test::Nebulous->setup;

# ->new()
{
    my $neb = Nebulous::Server->new( trace => 'off' );

    ok($neb, "set log level");
}

Test::Nebulous->setup;

{
    my $neb = Nebulous::Server->new(
        dsn         => "DBI:mysql:database=foobar:host=localhost",
        dbuser      => "baz",
        dbpasswd    =>"boo",
    );

    ok($neb, "set database");
}

Test::Nebulous->setup;

# add dbs after ->new()
{
    my $neb = Nebulous::Server->new;

    ok($neb->config->add_db(
        dbindex    => 0,
        dsn         => "DBI:mysql:database=foobar:host=localhost",
        dbuser      => "baz",
        dbpasswd    =>"boo",
    ), "add db");
    
    ok($neb->config->add_db(
        dbindex    => 1,
        dsn         => "DBI:mysql:database=foobar:host=localhost",
        dbuser      => "baz",
        dbpasswd    =>"boo",
    ), "add dbs");

    is($neb->config->n_db, 2, "n dbs")
}

Test::Nebulous->cleanup;
