Commit | Line | Data |
0567538f |
1 | sub run_tests { |
1edaf6fe |
2 | my $schema = shift; |
0567538f |
3 | |
a953d8d9 |
4 | plan tests => 3; |
0567538f |
5 | |
6 | # add some rows inside a transaction and commit it |
7 | # XXX: Is storage->dbh the only way to get a dbh? |
f9db5527 |
8 | $schema->storage->txn_begin; |
0567538f |
9 | for (10..15) { |
f9db5527 |
10 | $schema->resultset("Artist")->create( { |
0567538f |
11 | artistid => $_, |
12 | name => "artist number $_", |
13 | } ); |
14 | } |
f9db5527 |
15 | $schema->storage->txn_commit; |
16 | my ($artist) = $schema->resultset("Artist")->find(15); |
0567538f |
17 | is($artist->name, 'artist number 15', "Commit ok"); |
18 | |
0567538f |
19 | # add some rows inside a transaction and roll it back |
f9db5527 |
20 | $schema->storage->txn_begin; |
0567538f |
21 | for (21..30) { |
f9db5527 |
22 | $schema->resultset("Artist")->create( { |
0567538f |
23 | artistid => $_, |
24 | name => "artist number $_", |
25 | } ); |
26 | } |
f9db5527 |
27 | $schema->storage->txn_rollback; |
28 | ($artist) = $schema->resultset("Artist")->search( artistid => 25 ); |
0567538f |
29 | is($artist, undef, "Rollback ok"); |
30 | |
a953d8d9 |
31 | my $type_info = $schema->storage->columns_info_for('artist'); |
b3caf56c |
32 | |
33 | # I know this is gross but SQLite reports the size differently from release |
34 | # to release. At least this way the test still passes. |
35 | |
36 | delete $type_info->{artistid}{size}; |
37 | delete $type_info->{name}{size}; |
38 | |
a953d8d9 |
39 | my $test_type_info = { |
40 | 'artistid' => { |
fc22fbac |
41 | 'data_type' => 'INTEGER', |
42 | 'is_nullable' => 0, |
a953d8d9 |
43 | }, |
44 | 'name' => { |
fc22fbac |
45 | 'data_type' => 'varchar', |
46 | 'is_nullable' => 0, |
93cec8c3 |
47 | }, |
a953d8d9 |
48 | }; |
49 | is_deeply($type_info, $test_type_info, 'columns_info_for - column data types'); |
50 | |
0567538f |
51 | } |
52 | |
53 | 1; |