check a couple more signals during sqlite health check
[dbsrgits/DBIx-Class.git] / t / bindtype_columns.t
1 use strict;
2 use warnings;  
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7
8 my ($dsn, $dbuser, $dbpass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/};
9
10 plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test'
11   unless ($dsn && $dbuser);
12   
13 plan tests => 6;
14
15 my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass, { AutoCommit => 1 });
16
17 my $dbh = $schema->storage->dbh;
18
19 {
20     local $SIG{__WARN__} = sub {};
21     $dbh->do('DROP TABLE IF EXISTS bindtype_test');
22
23     # the blob/clob are for reference only, will be useful when we switch to SQLT and can test Oracle along the way
24
25     # the blob/clob are for reference only, will be useful when we switch to SQLT and can test Oracle along the way
26     $dbh->do(qq[
27         CREATE TABLE bindtype_test 
28         (
29             id              serial       NOT NULL   PRIMARY KEY,
30             bytea           bytea        NULL,
31             blob            bytea        NULL,
32             clob            text         NULL
33         );
34     ],{ RaiseError => 1, PrintError => 1 });
35 }
36
37 # test retrieval of the bytea column
38 {
39   my $row = $schema->resultset('BindType')->find({ id => $new->id });
40   is($row->get_column('bytea'), $big_long_string, "Created the blob correctly.");
41 }
42
43 my $new = $schema->resultset('BindType')->create({ bytea => $big_long_string });
44
45 ok($new->id, "Created a bytea row");
46 is($new->bytea,         $big_long_string, "Set the blob correctly.");
47
48 my $rs = $schema->resultset('BindType')->find({ id => $new->id });
49
50 is($rs->get_column('bytea'), $big_long_string, "Created the blob correctly.");
51
52 $dbh->do("DROP TABLE bindtype_test");
53
54 $dbh->do("DROP TABLE bindtype_test");