fix bogus tests
[dbsrgits/DBIx-Class-Journal.git] / t / 03populate.t
index c6fa507..debc4df 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     eval "use DBD::SQLite; use SQL::Translator";
     plan $@
         ? ( skip_all => 'needs DBD::SQLite and SQL::Translator for testing' )
-        : ( tests => 21 );
+        : ( tests => 11 );
 }
 
 use lib qw(t/lib);
@@ -14,9 +14,9 @@ use DBICTest;
 
 # connect to db and deploy only the original db schema, not journal schema
 my $schema = DBICTest->init_schema(no_populate => 1, no_deploy => 1);
-$schema->deploy;
 
 ok($schema, 'Created a Schema');
+$schema->deploy;
 
 # check we have no journal
 my $count = eval {
@@ -28,16 +28,13 @@ is( $count, undef, 'no count' );
 like( $e, qr/table.*changelog/, 'missing table error' );
 
 # insert two rows -not- in txn
-my ($artistA, $artistB);
-#$schema->txn_do(sub {
-    $artistA = $schema->resultset('Artist')->create({
-        name => 'Fred Bloggs A',
-    });
-
-    $artistB = $schema->resultset('Artist')->create({
-        name => 'Fred Bloggs B',
-    });
-#});
+$schema->storage->dbh_do(sub {
+   my $dbh = $_[1];
+   $dbh->do($_) for (
+     "INSERT INTO artist ( name ) VALUES ('Fred Bloggs A' )",
+     "INSERT INTO artist ( name ) VALUES ('Fred Bloggs B' )"
+   );
+});
 
 # create the journal
 $schema->journal_schema_deploy();
@@ -46,7 +43,7 @@ $schema->journal_schema_deploy();
 $count = eval { $schema->_journal_schema->resultset('ChangeLog')->count };
 
 is( $@, '', "no error" );
-is( $count, 0, "count is 0 (chagnelog)" );
+is( $count, 0, "count is 0 (changelog)" );
 
 # run populate
 $schema->prepopulate_journal();
@@ -69,31 +66,3 @@ $count = eval { $schema->_journal_schema->resultset('ArtistAuditLog')->count };
 is( $@, '', "no error" );
 is( $count, 2, "count is 2 (auditlog)" );
 
-# now delete a row
-eval {
-    my $deleted = $schema->txn_do(sub {
-        $artistA->delete;
-    });
-};
-
-is( $@, '', "no error from deletion journal (create_id not null)" );
-is( $artistA->in_storage, 0, "row was deleted" );
-
-# check journal log still has two rows
-$count = eval { $schema->_journal_schema->resultset('ArtistAuditLog')->count };
-
-is( $@, '', "no error" );
-is( $count, 2, "count is 2 (auditlog 2)" );
-
-# and that one of them has a delete_id
-$count = eval {
-    $schema->_journal_schema->resultset('ArtistAuditLog')
-        ->search({
-            artistid => $artistA->id,
-            delete_id => { '-not' => undef }
-        })->count;
-};
-    
-is( $@, '', "no error" );
-is( $count, 1, "count is 1 (delete_id)" );
-