DBIx-Custom / t / private-postgresql.t /
Newer Older
46 lines | 1.005kb
added postgresql test
Yuki Kimoto authored on 2011-08-06
1
use Test::More;
2
use strict;
3
use warnings;
4
use FindBin;
5
use DBIx::Custom;
6

            
7

            
8
$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/};
9

            
10
# Constant
11
my $user = 'dbix_custom';
12
my $password = 'dbix_custom';
13
my $database = 'dbix_custom';
14
my %connect_args_default = (
15
        dsn => "dbi:Pg:dbname=$database",
16
        user => $user,
17
        password => $password
18
);
19
my $create_table_default = 'create table table1 (key1 varchar(255), key2 varchar(255));';
20

            
21
plan skip_all => 'private test'
22
  unless -f "$FindBin::Bin/private-postgresql-run.tmp"
23
    && eval { DBIx::Custom->connect(%connect_args_default); 1 };
24

            
25
plan 'no_plan';
26

            
27

            
28
# Variable
29
my $dbi;
30
my $model;
31

            
32
# Connect
33
eval { $dbi = DBIx::Custom->connect(%connect_args_default); 1 };
34
ok(!$@);
35

            
36
# Drop table
37
eval { $dbi->execute('drop table table1') };
38

            
39
# Create table
40
$dbi->execute($create_table_default);
41
$model = $dbi->create_model(table => 'table1');
42
$model->insert({key1 => 1, key2 => 2});
43
is_deeply($model->select->all, [{key1 => 1, key2 => 2}]);
44

            
45

            
46