refactored test suite

This commit is contained in:
Florian "flowdy" Heß 2016-05-22 15:13:19 +02:00
parent 7a0d08ae50
commit 4ad8e8d528
2 changed files with 70 additions and 14 deletions

30
schema.t.out Normal file
View File

@ -0,0 +1,30 @@
ID: credit promise debt
--------------------------------
Club: 0 +7200 -23450
john: 7200 +0 -7200
# Reflect john paying its bills all at once ...
Club: 7200 +0 -23450
john: 0 +0 0
# Charge Club with server hosting provided by alex ...
Club: 0 +0 -16250
alex: 7200 +16250 0
# Some updates and deletes that could, unless denied, destroy consistency ...
Error: near line 274: paid is set and adjusted automatically according to added Transfer records
Error: near line 275: Debt is involved in transfers to revoke at first
Error: near line 276: 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
# But let's rollback that what-if excurse. This is how it currently is ...
Club: 0 +0 -16250
alex: 7200 +16250 0
###################################################################
# Now it is your turn: Study the sql code yielding the output above
# then enter new members and let them pay the fees.
# (PLUS: Let have one discalculia and pay too little or too much.)
# Once the club has enough money to pay alex' hosting service,
# update (i.e. revoke and reenter) the respective transaction.
# Finally issue a bank transfer to alex. Hint: An outgoing transfer
# is simply a debt charging alex' own virtual account and without
# targetCredit (NULL). PLUS: What happens if the description of
# the bank transfer does not contain any or only a wrong IBAN?

View File

@ -1,5 +1,7 @@
PRAGMA foreign_keys = ON;
-- To understand the sql below, see the schema.sql file.
INSERT INTO Account VALUES ("Club", "eV", 1, NULL), ("john", "Member", 44, NULL), ("alex", "Member", 6, "DE1234567890123456");
INSERT INTO Credit VALUES (1, "Club", "2016-01-01", "Membership fees May 2016 until incl. April 2017", 0, 0),
@ -21,18 +23,42 @@ INSERT INTO Debit VALUES ("MB1605-john", "john", 1, "2016-05-01", "Membership fe
("TWX2016/123", "Club", 3, "2016-01-15", "Server Hosting 2016", 23450, 0);
.separator " "
SELECT "Balance of " || ID || "'s account:", credit, debit * -1 FROM Balance WHERE ID in ("john", "Club");
INSERT INTO Transfer (receiptId, fromCredit) VALUES ("MB1605-john", 2), ("MB1606-john", 2), ("MB1607-john", 2), ("MB1608-john", 2), ("MB1609-john", 2), ("MB1610-john", 2), ("MB1611-john", 2), ("MB1612-john", 2), ("MB1701-john", 2), ("MB1702-john", 2), ("MB1703-john", 2), ("MB1704-john", 2);
SELECT "Balance of " || ID || "'s account:", credit, debit * -1 FROM Balance WHERE ID in ("john", "Club");
INSERT INTO Transfer (receiptId, fromCredit) VALUES ("TWX2016/123", 1);
SELECT "Balance of " || ID || "'s Account:", credit, debit * -1 FROM Balance WHERE ID in ("Club", "alex");
UPDATE Debit SET paid = 20000 WHERE receiptId="TWX2016/123";
UPDATE Debit SET value = 20000 WHERE receiptId="TWX2016/123";
DELETE FROM Debit WHERE receiptId="TWX2016/123"; -- *SHOULD NOT* work
SELECT "ID: credit promise debt";
SELECT "--------------------------------";
SELECT ID || ":", credit, '+' || promised, debt * -1 FROM Balance WHERE ID in ("john", "Club");
SELECT "# Reflect john paying its bills all at once ...";
INSERT INTO Transfer (billId, fromCredit) VALUES ("MB1605-john", 2), ("MB1606-john", 2), ("MB1607-john", 2), ("MB1608-john", 2), ("MB1609-john", 2), ("MB1610-john", 2), ("MB1611-john", 2), ("MB1612-john", 2), ("MB1701-john", 2), ("MB1702-john", 2), ("MB1703-john", 2), ("MB1704-john", 2);
SELECT ID || ":", credit, '+' || promised, debt * -1 FROM Balance WHERE ID in ("john", "Club");
SELECT "# Charge Club with server hosting provided by alex ...";
INSERT INTO Transfer (billId, fromCredit) VALUES ("TWX2016/123", 1);
SELECT ID || ":", credit, '+' || promised, debt * -1 FROM Balance WHERE ID in ("Club", "alex");
SELECT "# Some updates and deletes that could, unless denied, destroy consistency ...";
UPDATE Debit SET paid = 20000 WHERE billId="TWX2016/123";
UPDATE Debit SET value = 20000 WHERE billId="TWX2016/123";
DELETE FROM Debit WHERE billId="TWX2016/123"; -- *SHOULD NOT* work
SELECT "# After revoking transactions, you are free to change or delete debts and credits ...";
BEGIN TRANSACTION;
DELETE FROM Transfer WHERE receiptId="TWX2016/123";
UPDATE Debit SET value = 20000 WHERE receiptId="TWX2016/123";
DELETE FROM Debit WHERE receiptId="TWX2016/123"; -- *SHOULD* work
SELECT "Balance of " || ID || "'s Account:", credit, debit * -1 FROM Balance WHERE ID in ("Club", "alex");
DELETE FROM Transfer WHERE billId="TWX2016/123";
UPDATE Debit SET value = 20000 WHERE billId="TWX2016/123";
DELETE FROM Debit WHERE billId="TWX2016/123"; -- *SHOULD* work
SELECT ID || ":", credit, '+' || promised, debt * -1 FROM Balance WHERE ID in ("Club", "alex");
ROLLBACK TRANSACTION;
SELECT "Balance of " || ID || "'s Account:", credit, debit * -1 FROM Balance WHERE ID in ("Club", "alex");
SELECT '# But let''s rollback that what-if excurse. This is how it currently is ...';
SELECT ID || ":", credit, '+' || promised, debt * -1 FROM Balance WHERE ID in ("Club", "alex");
SELECT '###################################################################';
SELECT '# Now it is your turn: Study the sql code yielding the output above';
SELECT '# then enter new members and let them pay the fees.';
SELECT '# (PLUS: Let have one discalculia and pay too little or too much.)';
SELECT '# Once the club has enough money to pay alex'' hosting service,';
SELECT '# update (i.e. revoke and reenter) the respective transaction.';
SELECT '# Finally issue a bank transfer to alex. Hint: An outgoing transfer';
SELECT '# is simply a debt charging alex'' own virtual account and without';
SELECT '# targetCredit (NULL). PLUS: What happens if the description of';
SELECT '# the bank transfer does not contain any or only a wrong IBAN?';