diff options
| author | Masaya Tojo <masaya@tojo.tokyo> | 2023-03-27 04:01:47 +0900 | 
|---|---|---|
| committer | Masaya Tojo <masaya@tojo.tokyo> | 2023-03-27 04:01:47 +0900 | 
| commit | 6b8ab6fe190e9d8f42242ff1f57be8c28e9ca066 (patch) | |
| tree | f608d39d4f2a33652aba5ebc00d705d1d14ccd88 /verify | |
| parent | 0a8e2a6e5dc7d75017f81d90ce1eb904280f1cba (diff) | |
Delete insert/delete functions.
Diffstat (limited to 'verify')
| -rw-r--r-- | verify/delete_item.sql | 37 | ||||
| -rw-r--r-- | verify/delete_transaction.sql | 43 | ||||
| -rw-r--r-- | verify/insert_item.sql | 31 | ||||
| -rw-r--r-- | verify/insert_transaction.sql | 26 | 
4 files changed, 0 insertions, 137 deletions
| diff --git a/verify/delete_item.sql b/verify/delete_item.sql deleted file mode 100644 index b1c3dd7..0000000 --- a/verify/delete_item.sql +++ /dev/null @@ -1,37 +0,0 @@ --- Verify kakeibo:delete_item on pg - -BEGIN; - -SELECT has_function_privilege('kakeibo.delete_item(INTEGER)', 'EXECUTE'); - -SET search_path = kakeibo; - -DO $$ -  DECLARE -    v_transaction_id INTEGER; -    v_item_id INTEGER; -    v_item_id_2 INTEGER; -  BEGIN -    SELECT insert_transaction(0, '2023-03-15', 'テスト') INTO v_transaction_id; -    SELECT insert_item(v_transaction_id, 'カテ', 'サブカテ', 298, 'メモ') INTO v_item_id; -    SELECT insert_item(v_transaction_id, 'カテ', 'サブカテ', 298, 'メモ') INTO v_item_id_2; - -    PERFORM * FROM items WHERE id = v_item_id; -    IF NOT FOUND THEN -      RAISE EXCEPTION 'Inserted data is not found.'; -    END IF; - -    PERFORM delete_item(v_item_id); -    PERFORM * FROM items WHERE id = v_item_id; -    IF FOUND THEN -      RAISE EXCEPTION 'Deleted data still exists.'; -    END IF; - -    PERFORM * FROM items WHERE id = v_item_id_2; -    IF NOT FOUND THEN -      RAISE EXCEPTION 'Unexpected delete data.'; -    END IF; -  END -$$; - -ROLLBACK; diff --git a/verify/delete_transaction.sql b/verify/delete_transaction.sql deleted file mode 100644 index 9f4d1d8..0000000 --- a/verify/delete_transaction.sql +++ /dev/null @@ -1,43 +0,0 @@ --- Verify kakeibo:delete_transaction on pg - -BEGIN; - -SELECT has_function_privilege('kakeibo.delete_transaction(INTEGER)', 'EXECUTE'); - -SET search_path = kakeibo; - -DO $$ -  DECLARE -    v_transaction_id INTEGER; -    v_transaction_id_2 INTEGER; -    v_item_id INTEGER; -  BEGIN -    SELECT insert_transaction(0, '2023-03-15', 'テスト') INTO v_transaction_id; -    SELECT insert_transaction(1, '2023-03-15', 'テスト2') INTO v_transaction_id_2; -    SELECT insert_item(v_transaction_id, 'カテ', 'サブカテ', 298, 'メモ') INTO v_item_id; - -    BEGIN -      PERFORM delete_transaction(v_transaction_id); -    EXCEPTION -      WHEN foreign_key_violation THEN -    END; -    PERFORM * FROM transactions WHERE id = v_transaction_id; -    IF NOT FOUND THEN -      RAISE EXCEPTION 'Unexpected delete data.'; -    END IF; - -    PERFORM delete_item(v_item_id); -    PERFORM delete_transaction(v_transaction_id); -    PERFORM * FROM transactions WHERE id = v_transaction_id; -    IF FOUND THEN -      RAISE EXCEPTION 'Deleted data still exists.'; -    END IF; - -    PERFORM * FROM transactions WHERE id = v_transaction_id_2; -    IF NOT FOUND THEN -      RAISE EXCEPTION 'Unexpected delete data.'; -    END IF; -  END -$$; - -ROLLBACK; diff --git a/verify/insert_item.sql b/verify/insert_item.sql deleted file mode 100644 index f1ce212..0000000 --- a/verify/insert_item.sql +++ /dev/null @@ -1,31 +0,0 @@ --- Verify kakeibo:insert_item on pg - -BEGIN; - -SELECT has_function_privilege('kakeibo.insert_item(INTEGER, TEXT, TEXT, INTEGER, TEXT)', 'EXECUTE'); - -SET search_path = kakeibo; - -DO $$ -  DECLARE -    v_transaction_id INTEGER; -    v_item_id INTEGER; -  BEGIN -    SELECT insert_transaction(0, '2023-03-15', 'テスト') INTO v_transaction_id; -    SELECT insert_item(v_transaction_id, 'カテ', 'サブカテ', 298, 'メモ') INTO v_item_id; - -    PERFORM * -      FROM items -      WHERE id = v_item_id -      AND transaction_id = v_transaction_id -      AND category = 'カテ' -      AND subcategory = 'サブカテ' -      AND amount = 298 -      AND note = 'メモ'; -    IF NOT FOUND THEN -      RAISE EXCEPTION 'Inserted data is not found.'; -    END IF; -  END -$$; - -ROLLBACK; diff --git a/verify/insert_transaction.sql b/verify/insert_transaction.sql deleted file mode 100644 index 7f6893c..0000000 --- a/verify/insert_transaction.sql +++ /dev/null @@ -1,26 +0,0 @@ --- 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; | 
