aboutsummaryrefslogtreecommitdiff
path: root/verify
diff options
context:
space:
mode:
Diffstat (limited to 'verify')
-rw-r--r--verify/insert_transaction.sql26
1 files changed, 26 insertions, 0 deletions
diff --git a/verify/insert_transaction.sql b/verify/insert_transaction.sql
new file mode 100644
index 0000000..7f6893c
--- /dev/null
+++ b/verify/insert_transaction.sql
@@ -0,0 +1,26 @@
+-- Verify kakeibo:insert_transaction on pg
+
+BEGIN;
+
+SELECT has_function_privilege('kakeibo.insert_transaction(INTEGER, DATE, TEXT)', 'EXECUTE');
+
+SET search_path = kakeibo;
+
+DO $$
+ DECLARE
+ v_id INTEGER;
+ BEGIN
+ SELECT insert_transaction(0, '2023-03-15', 'テスト') INTO v_id;
+ PERFORM *
+ FROM transactions
+ WHERE id = v_id
+ AND type_code = 0
+ AND date = '2023-03-15'
+ AND note = 'テスト';
+ IF NOT FOUND THEN
+ RAISE EXCEPTION 'Inserted data is not found.';
+ END IF;
+ END
+$$;
+
+ROLLBACK;