10 eval "use DBD::SQLite";
12 ? ( skip_all => 'needs DBD::SQLite for testing' )
16 my $schema = DBICTest->init_schema(no_populate => 1);
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');
25 warn $schema->_journal_schema->resultset('ArtistAuditLog')->count;
29 is( $count, undef, "no count" );
30 like( $e, qr/table.*artist_audit_log/i, "missing table error" );
33 $schema->journal_schema_deploy();
36 my $new_cd = $schema->txn_do( sub {
37 $artist = $schema->resultset('Artist')->create({
38 name => 'Fred Bloggs',
40 return $schema->resultset('CD')->create({
41 title => 'Angry young man',
46 isa_ok($new_cd, 'DBIx::Class::Journal', 'Created CD object');
48 my $search = $schema->_journal_schema->resultset('CDAuditLog')->search();
49 ok($search->count, 'Created an entry in the CD audit log');
51 $schema->txn_do( sub {
56 is($new_cd->year, 2003, 'Changed year to 2003');
57 my $cdah = $schema->_journal_schema->resultset('CDAuditHistory')->search();
58 ok($cdah->count, 'Created an entry in the CD audit history');
60 $schema->txn_do( sub {
61 $schema->resultset('CD')->create({
68 $schema->txn_do( sub {
72 my $alentry = $search->find({ ID => $new_cd->get_column($new_cd->primary_columns) });
73 ok(defined($alentry->deleted), 'Deleted set in audit_log');
75 $schema->changeset_user(1);
76 $schema->txn_do( sub {
77 $schema->resultset('CD')->create({
78 title => 'Something 2',
84 ok($search->count > 1, 'Created an second entry in the CD audit history');
86 my $cset = $schema->_journal_schema->resultset('ChangeSet')->find(5);
87 is($cset->user_id, 1, 'Set user id for 5th changeset');
89 $schema->changeset_session(1);
90 $schema->txn_do( sub {
91 $schema->resultset('CD')->create({
92 title => 'Something 3',
98 my $cset2 = $schema->_journal_schema->resultset('ChangeSet')->find(6);
99 is($cset2->session_id, 1, 'Set session id for 6th changeset');