Remove all uses of Scope::Guard from the tests, use our own version
[dbsrgits/DBIx-Class.git] / t / resultset / update_delete.t
index 7d9efa9..30e3797 100644 (file)
@@ -10,6 +10,8 @@ use Test::Exception;
 # and that's a whole another bag of dicks
 BEGIN { $ENV{DBIC_SHUFFLE_UNORDERED_RESULTSETS} = 0 }
 
+use DBIx::Class::_Util 'scope_guard';
+
 use DBICTest::Schema::CD;
 BEGIN {
   # the default scalarref table name will not work well for this test
@@ -140,7 +142,13 @@ $schema->is_executed_sql_bind( sub {
 
 # try the same sql with forced multicolumn in
 $schema->is_executed_sql_bind( sub {
-  local $schema->storage->{_use_multicolumn_in} = 1;
+
+  my $orig_umi = $schema->storage->_use_multicolumn_in;
+  my $sg = scope_guard {
+    $schema->storage->_use_multicolumn_in($orig_umi);
+  };
+
+  $schema->storage->_use_multicolumn_in(1);
 
   # this can't actually execute on sqlite
   eval { $fks_multi->update ({ read_count => \ 'read_count + 1' }) };
@@ -280,6 +288,10 @@ cmp_ok ($tkfk_cnt, '>', 1, 'More than 1 row left');
 $tkfks->search ({}, { rows => 1 })->delete;
 is ($tkfks->count, $tkfk_cnt -= 1, 'Only one row deleted');
 
+throws_ok {
+  $tkfks->search ({}, { rows => 0 })->delete
+} qr/rows attribute must be a positive integer/;
+is ($tkfks->count, $tkfk_cnt, 'Nothing deleted');
 
 # check with sql-equality, as sqlite will accept most bad sql just fine
 {