chiark / gitweb /
Testing: Reorganise files, variables, etc.
[cgi-auth-flexible.git] / tests / commit-test.pl
diff --git a/tests/commit-test.pl b/tests/commit-test.pl
new file mode 100755 (executable)
index 0000000..69a0640
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/perl -w
+
+use warnings;
+use strict;
+use DBI;
+
+my $dsn = "dbi:SQLite:dbname=test.db";
+my $dbh = DBI->connect($dsn, '','', { 
+                            AutoCommit => 0, RaiseError => 1,
+                        });
+
+foreach my $v (@ARGV) {
+    if (!eval {
+       if ($v eq 'bw') { $dbh->begin_work or die; }
+       elsif ($v eq 'rb') { $dbh->rollback or die; }
+       elsif ($v eq 'ci') { $dbh->commit or die; }
+       elsif ($v eq 'dc') { $dbh->disconnect or die; }
+       elsif ($v eq 'ct') { $dbh->do('CREATE TABLE t (f TEXT)') or die; }
+       elsif ($v eq 'i') { $dbh->do('INSERT INTO t VALUES ("x")') or die; }
+       else { die; }
+       1;
+    }) {
+       warn $@;
+    }
+}