Merge 'trunk' into 'replication_dedux'
[dbsrgits/DBIx-Class.git] / t / 64db.t
1 use strict;
2 use warnings;  
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7
8 my $schema = DBICTest->init_schema();
9
10 plan tests => 3;
11
12 # add some rows inside a transaction and commit it
13 # XXX: Is storage->dbh the only way to get a dbh?
14 $schema->storage->txn_begin;
15 for (10..15) {
16     $schema->resultset("Artist")->create( { 
17         artistid => $_,
18         name => "artist number $_",
19     } );
20 }
21 $schema->storage->txn_commit;
22 my ($artist) = $schema->resultset("Artist")->find(15);
23 is($artist->name, 'artist number 15', "Commit ok");
24
25 # add some rows inside a transaction and roll it back
26 $schema->storage->txn_begin;
27 for (21..30) {
28     $schema->resultset("Artist")->create( {
29         artistid => $_,
30         name => "artist number $_",
31     } );
32 }
33 $schema->storage->txn_rollback;
34 ($artist) = $schema->resultset("Artist")->search( artistid => 25 );
35 is($artist, undef, "Rollback ok");
36
37 my $type_info = $schema->storage->columns_info_for('artist');
38
39 # I know this is gross but SQLite reports the size differently from release
40 # to release. At least this way the test still passes.
41
42 delete $type_info->{artistid}{size};
43 delete $type_info->{name}{size};
44
45 my $test_type_info = {
46     'artistid' => {
47         'data_type' => 'INTEGER',
48         'is_nullable' => 0,
49     },
50     'name' => {
51         'data_type' => 'varchar',
52         'is_nullable' => 0,
53     },
54 };
55 is_deeply($type_info, $test_type_info, 'columns_info_for - column data types');
56