File: 610-output-getinstance.t

package info (click to toggle)
libparse-dia-sql-perl 0.31-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 924 kB
  • sloc: perl: 3,865; makefile: 2
file content (44 lines) | stat: -rw-r--r-- 1,002 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#   $Id: 610-output-getinstance.t,v 1.3 2009/02/28 06:54:57 aff Exp $

use warnings;
use strict;

use Data::Dumper;
use Test::More;
use Test::Exception;  # test code that dies
use File::Spec::Functions;
use lib catdir qw ( blib lib );

plan tests => 8;

use lib q{lib};
use_ok ('Parse::Dia::SQL');
use_ok ('Parse::Dia::SQL::Logger');

my $diasql = undef;

# Test that lives - db => 'db2'
$diasql = Parse::Dia::SQL->new(db => 'db2');
isa_ok($diasql, 'Parse::Dia::SQL');

# Fool Parse::Dia::SQL into thinking convert() was called
$diasql->{converted} = 1; 

my $subclass = undef;
lives_ok(
  sub { $subclass = $diasql->get_output_instance(); },
  q{get_output_instance (db2) should not die}
);
isa_ok($subclass, 'Parse::Dia::SQL::Output::DB2');

# Test that dies - db => 'foo'
undef $diasql;
ok(Parse::Dia::SQL::Logger::log_off());
throws_ok(
  sub { $diasql = Parse::Dia::SQL->new(db => 'foo'); },
  qr/Unsupported database/i,
  q{new(foo) should die}
);
ok(Parse::Dia::SQL::Logger::log_on());

__END__