[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 0cb9e47d24 227/427: Test all available backends.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 0cb9e47d24 227/427: Test all available backends. |
Date: |
Tue, 13 Dec 2022 02:59:46 -0500 (EST) |
branch: elpa/emacsql
commit 0cb9e47d24e439ddd31c7cf971f47a9306083e6d
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Test all available backends.
---
emacsql-tests.el | 87 +++++++++++++++++++++++++++++++++++---------------------
1 file changed, 54 insertions(+), 33 deletions(-)
diff --git a/emacsql-tests.el b/emacsql-tests.el
index 4172dd8ad5..15ca448a42 100644
--- a/emacsql-tests.el
+++ b/emacsql-tests.el
@@ -5,10 +5,26 @@
(require 'ert)
(require 'emacsql)
(require 'emacsql-sqlite)
+(require 'emacsql-psql)
(defvar emacsql-tests-timeout 4
"Be aggressive about not waiting on subprocesses in unit tests.")
+(defvar emacsql-tests-connection-factories
+ (let ((factories ())
+ (pgdatabase (getenv "PGDATABASE")))
+ (push (cons "sqlite" (apply-partially #'emacsql-sqlite nil)) factories)
+ (when pgdatabase
+ (push (cons "psql" (apply-partially #'emacsql-psql pgdatabase))
+ factories))
+ (nreverse factories))
+ "List of connection factories to use in unit tests.")
+
+;; Print testing information
+(princ (format "\nTesting %d database(s): %S\n"
+ (length emacsql-tests-connection-factories)
+ (mapcar #'car emacsql-tests-connection-factories)))
+
(ert-deftest emacsql-escape-identifier ()
(should (string= (emacsql-escape-identifier "foo") "foo"))
(should (string= (emacsql-escape-identifier 'foo) "foo"))
@@ -213,32 +229,35 @@
(ert-deftest emacsql-system ()
"A short test that fully interacts with SQLite."
(let ((emacsql-global-timeout emacsql-tests-timeout))
- (emacsql-with-connection (db (emacsql-sqlite nil))
- (emacsql db [:create-table foo [x]])
- (should-error (emacsql db [:create-table foo [x]]))
- (emacsql db [:insert :into foo :values ([1] [2] [3])])
- (should (equal (emacsql db [:select * :from foo])
- '((1) (2) (3)))))))
+ (dolist (factory emacsql-tests-connection-factories)
+ (emacsql-with-connection (db (funcall (cdr factory)))
+ (emacsql db [:create-table (:temporary foo) [x]])
+ (should-error (emacsql db [:create-table (:temporary foo) [x]]))
+ (emacsql db [:insert :into foo :values ([1] [2] [3])])
+ (should (equal (emacsql db [:select * :from foo])
+ '((1) (2) (3))))))))
(ert-deftest emacsql-foreign-system ()
"Tests that foreign keys work properly through Emacsql."
(let ((emacsql-global-timeout emacsql-tests-timeout))
- (emacsql-with-connection (db (emacsql-sqlite nil))
- (emacsql-thread db
- [:create-table person [(id integer :primary) name]]
- [:create-table likes
- ([(personid integer) color]
- :references (personid person id :on-delete :cascade))]
- [:replace :into person :values ([0 "Chris"] [1 "Brian"])])
- (should (equal (emacsql db [:select * :from person :order-by id])
- '((0 "Chris") (1 "Brian"))))
- (emacsql db [:insert :into likes :values ([0 red] [0 yellow] [1
yellow])])
- (should (equal (emacsql db [:select * :from likes
- :order-by [personid color]])
- '((0 red) (0 yellow) (1 yellow))))
- (emacsql db [:delete :from person :where (= id 0)])
- (should (equal (emacsql db [:select * :from likes])
- '((1 yellow)))))))
+ (dolist (factory emacsql-tests-connection-factories)
+ (emacsql-with-connection (db (funcall (cdr factory)))
+ (emacsql-thread db
+ [:create-table (:temporary person) [(id integer :primary) name]]
+ [:create-table (:temporary likes)
+ ([(personid integer) color]
+ :references (personid person id :on-delete
:cascade))]
+ [:insert :into person :values ([0 "Chris"] [1 "Brian"])])
+ (should (equal (emacsql db [:select * :from person :order-by id])
+ '((0 "Chris") (1 "Brian"))))
+ (emacsql db [:insert :into likes
+ :values ([0 red] [0 yellow] [1 yellow])])
+ (should (equal (emacsql db [:select * :from likes
+ :order-by [personid color]])
+ '((0 red) (0 yellow) (1 yellow))))
+ (emacsql db [:delete :from person :where (= id 0)])
+ (should (equal (emacsql db [:select * :from likes])
+ '((1 yellow))))))))
(ert-deftest emacsql-error ()
"Check that we're getting expected conditions."
@@ -249,21 +268,23 @@
(should-error (emacsql-compile nil [:insert :into foo :values 1])
:type 'emacsql-syntax)
(let ((emacsql-global-timeout emacsql-tests-timeout))
- (emacsql-with-connection (db (emacsql-sqlite nil))
- (emacsql db [:create-table foo [x]])
- (should-error (emacsql db [:create-table foo [x]])
- :type 'emacsql-error))))
+ (dolist (factory emacsql-tests-connection-factories)
+ (emacsql-with-connection (db (funcall (cdr factory)))
+ (emacsql db [:create-table (:temporary foo) [x]])
+ (should-error (emacsql db [:create-table (:temporary foo) [x]])
+ :type 'emacsql-error)))))
(ert-deftest emacsql-special-chars ()
"A short test that interacts with SQLite with special characters."
(let ((emacsql-global-timeout 4))
- (emacsql-with-connection (db (emacsql-sqlite nil))
- (emacsql db [:create-table test-table [x]])
- (emacsql db [:insert :into test-table
- :values ([""] [\])])
- (should (process-live-p (emacsql-process db)))
- (should (equal (emacsql db [:select * :from test-table])
- '(("") (\)))))))
+ (dolist (factory emacsql-tests-connection-factories)
+ (emacsql-with-connection (db (funcall (cdr factory)))
+ (emacsql db [:create-table (:temporary test-table) [x]])
+ (emacsql db [:insert :into test-table
+ :values ([""] [\])])
+ (should (process-live-p (emacsql-process db)))
+ (should (equal (emacsql db [:select * :from test-table])
+ '(("") (\))))))))
(provide 'emacsql-tests)
- [nongnu] elpa/emacsql bec6af6940 148/427: Add VACUUM., (continued)
- [nongnu] elpa/emacsql bec6af6940 148/427: Add VACUUM., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 03aebdecd1 160/427: Rename :log option to :debug., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql bb221f6134 161/427: Drop .print command flushing., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 72b34f6522 173/427: Add some more autoloading., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3229cd41af 180/427: Change the requirements for front-end implementations., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 431a3b325f 200/427: Toss "reap" and switch to new finalize with Cask., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ed86b098ce 197/427: Add prefix arg to emacsql-show-last-sql., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 027c5df94e 209/427: Organize all the keywords in the README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1ebbc22411 212/427: Disable undo in process buffers., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 5bef799b6b 220/427: Make some tweaks to accommodate Windows., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 0cb9e47d24 227/427: Test all available backends.,
ELPA Syncer <=
- [nongnu] elpa/emacsql 730e4d882a 235/427: Fix up the README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4b45472ffa 240/427: Don't copy the binary every time., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c89ccf82df 241/427: Make a reconnect generic method., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 159195690d 245/427: Include bin/ in the package., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f98ee5e7cd 246/427: Use no-undo buffers., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 4b58a6717e 250/427: Don't use temporary tables in foreign key test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 462d1f1b31 252/427: Fix stupid backslash escape mode in MySQL., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b0f0d3085d 258/427: Get OS tuple from Emacs., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1b5891298a 255/427: Officially add MySQL to unit testing., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 127bb98df2 264/427: Set coding system to utf-8-auto for sqlite., ELPA Syncer, 2022/12/13