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