Refactored and united raw and ORM api tests
This commit is contained in:
parent
3985b46224
commit
bc37ee316b
@ -14,7 +14,7 @@ sub import {
|
||||
return if @_ == 1;
|
||||
croak "use TrsrDB \$your_db_handle missing" if !defined $dbh_ref;
|
||||
$$dbh_ref = $class->connect(
|
||||
"DBI:SQLite:" . ($filename // ":memory:"),
|
||||
"DBI:SQLite:" . ($filename // $ENV{TRSRDB_SQLITE_FILE} // ":memory:"),
|
||||
"", "", {
|
||||
sqlite_unicode => 1,
|
||||
on_connect_call => 'use_foreign_keys',
|
||||
|
@ -9,9 +9,9 @@ john: 0 +0 0
|
||||
Club: 0 +0 -16250
|
||||
alex: 7200 +16250 0
|
||||
# Some updates and deletes that could, unless denied, destroy consistency ...
|
||||
Error: near line 409: paid is set and adjusted automatically according to added Transfer records
|
||||
Error: near line 410: Debt is involved in transfers to revoke at first
|
||||
Error: near line 411: FOREIGN KEY constraint failed
|
||||
Error: near line 41: paid is set and adjusted automatically according to added Transfer records
|
||||
Error: near line 42: Debt is involved in transfers to revoke at first
|
||||
Error: near line 43: FOREIGN KEY constraint failed
|
||||
# After revoking transactions, you are free to change or delete debts and credits ...
|
||||
Club: 7200 +0 0
|
||||
alex: 0 +0 0
|
||||
|
@ -1 +1,4 @@
|
||||
diff t/schema.out <(cat {,t/}schema.sql | sqlite3 2>&1)
|
||||
echo "My database file: $1"
|
||||
if sqlite3 $1 < schema.sql; then
|
||||
diff t/schema.out <(sqlite3 $1 < t/schema.sql 2>&1)
|
||||
fi
|
||||
|
@ -1,7 +1,7 @@
|
||||
use strict;
|
||||
|
||||
my $db;
|
||||
use TrsrDB \$db => 'trsr.db';
|
||||
use TrsrDB \$db => $ENV{TRSRDB_SQLITE_FILE};
|
||||
use Test::More;
|
||||
|
||||
$db->resultset("Account")->create({ ID => "Club", altId => 1, type => 'eV' });
|
||||
|
17
test.sh
17
test.sh
@ -1,5 +1,20 @@
|
||||
#!/bin/bash
|
||||
source t/schema.sh
|
||||
|
||||
abort () {
|
||||
echo Database not deleted.
|
||||
exit ${1:-1}
|
||||
}
|
||||
|
||||
db=$(mktemp -t trsr-XXXXXXXXX.db);
|
||||
bash t/schema.sh $db
|
||||
if [ $? == 0 ]; then
|
||||
echo Tests passed.
|
||||
else abort
|
||||
fi
|
||||
|
||||
> $db; sqlite3 $db < schema.sql
|
||||
export TRSRDB_SQLITE_FILE=$db
|
||||
if prove -r t; then
|
||||
rm $db
|
||||
else abort $?
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user