X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F01test.t;h=57da6862be00c725b308a7756b51153d485b20b5;hb=b15a2b3cb9e6c20be6057fe7226ec0b2fb3b45f0;hp=7b5b4f1518635f5c04b84329c2614af1bd6348ed;hpb=ec16e73a8dc1429581541a031a3bd95e0f9a3009;p=dbsrgits%2FDBIx-Class-Journal.git diff --git a/t/01test.t b/t/01test.t index 7b5b4f1..57da686 100644 --- a/t/01test.t +++ b/t/01test.t @@ -10,7 +10,7 @@ BEGIN { eval "use DBD::SQLite"; plan $@ ? ( skip_all => 'needs DBD::SQLite for testing' ) - : ( tests => 12 ); + : ( tests => 16 ); } my $schema = DBICTest->init_schema(no_populate => 1); @@ -22,17 +22,28 @@ isa_ok($schema->_journal_schema->source('ArtistAuditLog'), 'DBIx::Class::ResultS my $artist; my $new_cd = $schema->txn_do( sub { + my $current_changeset = $schema->_journal_schema->_current_changeset; + ok( $current_changeset, "have a current changeset" ); + $artist = $schema->resultset('Artist')->create({ name => 'Fred Bloggs', }); - return $schema->resultset('CD')->create({ - title => 'Angry young man', - artist => $artist, - year => 2000, + + $schema->txn_do(sub { + is( $current_changeset, $schema->_journal_schema->_current_changeset, "nested txn doesn't create a new changeset" ); + return $schema->resultset('CD')->create({ + title => 'Angry young man', + artist => $artist, + year => 2000, + }); }); }); isa_ok($new_cd, 'DBIx::Class::Journal', 'Created CD object'); +is( $schema->_journal_schema->_current_changeset, undef, "no current changeset" ); +eval { $schema->_journal_schema->current_changeset }; +ok( $@, "causes error" ); + my $search = $schema->_journal_schema->resultset('CDAuditLog')->search(); ok($search->count, 'Created an entry in the CD audit log'); @@ -57,7 +68,7 @@ $schema->txn_do( sub { $new_cd->delete; } ); -my $alentry = $search->find({ ID => $new_cd->get_column($new_cd->primary_columns) }); +my $alentry = $search->find({ map { $_ => $new_cd->get_column($_) } $new_cd->primary_columns }); ok(defined($alentry->deleted), 'Deleted set in audit_log'); $schema->changeset_user(1);