Debugging and tests, why do we get "database locked" with sqlite?
[dbsrgits/DBIx-Class-Journal.git] / t / 01test.t
1 use strict;
2 use warnings;  
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7 use Data::Dumper;
8
9 BEGIN {
10     eval "use DBD::SQLite";
11     plan $@
12         ? ( skip_all => 'needs DBD::SQLite for testing' )
13         : ( tests => 6 );
14 }
15
16 my $schema = DBICTest->init_schema(no_populate => 1);
17
18 ok($schema, 'Created a Schema');
19 isa_ok($schema->_journal_schema, 'DBIx::Class::Schema::Journal::DB', 'Actually have a schema object for the journaling');
20 isa_ok($schema->_journal_schema->source('CDAuditHistory'), 'DBIx::Class::ResultSource', 'CDAuditHistory source exists');
21 isa_ok($schema->_journal_schema->source('ArtistAuditLog'), 'DBIx::Class::ResultSource', 'ArtistAuditLog source exists');
22
23 my $new_cd = $schema->txn_do( sub {
24     my $artist = $schema->resultset('Artist')->create({
25         name => 'Fred Bloggs',
26     });
27     return  $schema->resultset('CD')->create({
28         title => 'Angry young man',
29         artist => $artist,
30         year => 2000,
31     });
32 });
33 isa_ok($new_cd, 'DBIx::Class::Journal', 'Created CD object');
34
35 my $search = $schema->_journal_schema->resultset('CDAuditLog')->search();
36 ok($search->count, 'Created an entry in the CD audit log');
37
38