[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql f52af86b05 124/427: Break apart and organize compi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql f52af86b05 124/427: Break apart and organize compilation tests. |
Date: |
Tue, 13 Dec 2022 02:59:34 -0500 (EST) |
branch: elpa/emacsql
commit f52af86b058f68de86834cd2e239b9cdc1d39826
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Break apart and organize compilation tests.
---
emacsql-tests.el | 69 ++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 45 insertions(+), 24 deletions(-)
diff --git a/emacsql-tests.el b/emacsql-tests.el
index 867678aef9..eb5fcc880c 100644
--- a/emacsql-tests.el
+++ b/emacsql-tests.el
@@ -54,32 +54,53 @@
(should (string= (apply #'emacsql-format (emacsql-expand query) args)
result)))
-(ert-deftest emacsql-expand ()
- (emacsql-tests-query [:select [$1 name] :from $2] '(id people)
- "SELECT id, name FROM people;")
- (emacsql-tests-query [:select * :from employees] ()
- "SELECT * FROM employees;")
- (emacsql-tests-query [:select * :from employees :where (< salary 50000)] ()
- "SELECT * FROM employees WHERE salary < 50000;")
- (emacsql-tests-query [:create-table foo [a b c]] ()
- "CREATE TABLE foo (a, b, c);")
- (emacsql-tests-query [:drop-table $1] '(foo)
- "DROP TABLE foo;")
- (emacsql-tests-query [:update people :set (= id $1)] '(10)
- "UPDATE people SET id = 10;")
- (emacsql-tests-query [:select * :from people :where (in name $1)] '([FOO
BAR])
- "SELECT * FROM people WHERE name IN ('FOO', 'BAR');")
- (emacsql-tests-query [:insert :into foo :values [nil $1]] '(10.1)
- "INSERT INTO foo VALUES (NULL, 10.1);")
- (emacsql-tests-query [:create-table (:temporary :if-not-exists x) [y]] '()
- "CREATE TEMPORARY TABLE IF NOT EXISTS x (y);"))
+(defmacro emacsql-tests-with-queries (&rest queries)
+ "Thread `emacsql-tests-query' through QUERIES."
+ (declare (indent 0))
+ (cons 'progn (mapcar (lambda (q) (cons 'emacsql-tests-query q)) queries)))
+
+(ert-deftest emacsql-select ()
+ (emacsql-tests-with-queries
+ ([:select [$1 name] :from $2] '(id people)
+ "SELECT id, name FROM people;")
+ ([:select * :from employees] '()
+ "SELECT * FROM employees;")
+ ([:select * :from employees :where (< salary 50000)] '()
+ "SELECT * FROM employees WHERE salary < 50000;")
+ ([:select * :from people :where (in name $1)] '([FOO BAR])
+ "SELECT * FROM people WHERE name IN ('FOO', 'BAR');")))
+
+(ert-deftest emacsql-create-table ()
+ (emacsql-tests-with-queries
+ ([:create-table foo [a b c]] ()
+ "CREATE TABLE foo (a, b, c);")
+ ([:create-table (:temporary :if-not-exists x) [y]] '()
+ "CREATE TEMPORARY TABLE IF NOT EXISTS x (y);")
+ ([:drop-table $1] '(foo)
+ "DROP TABLE foo;")))
+
+(ert-deftest emacsql-update ()
+ (emacsql-tests-with-queries
+ ([:update people :set (= id $1)] '(10)
+ "UPDATE people SET id = 10;")))
+
+(ert-deftest emacsql-insert ()
+ (emacsql-tests-with-queries
+ ([:insert :into foo :values [nil $1]] '(10.1)
+ "INSERT INTO foo VALUES (NULL, 10.1);")
+ ([:replace :into $1 :values $2] '(bar ([1 2] [3 4]))
+ "REPLACE INTO bar VALUES (1, 2), (3, 4);")))
(ert-deftest emacsql-order-by ()
- (emacsql-tests-query [:order-by foo] '() "ORDER BY foo;")
- (emacsql-tests-query [:order-by [$1]] '(bar) "ORDER BY bar;")
- (emacsql-tests-query [:order-by (- foo)] '() "ORDER BY -(foo);")
- (emacsql-tests-query [:order-by [(a :asc) ((/ b 2) :desc)]] '()
- "ORDER BY a ASC, b / 2 DESC;"))
+ (emacsql-tests-with-queries
+ ([:order-by foo] '()
+ "ORDER BY foo;")
+ ([:order-by [$1]] '(bar)
+ "ORDER BY bar;")
+ ([:order-by (- foo)] '()
+ "ORDER BY -(foo);")
+ ([:order-by [(a :asc) ((/ b 2) :desc)]] '()
+ "ORDER BY a ASC, b / 2 DESC;")))
(ert-deftest emacsql-system ()
(should-not (emacsql-sqlite3-unavailable-p))
- [nongnu] elpa/emacsql e956d91f99 095/427: Add -identifier to emacsql-escape., (continued)
- [nongnu] elpa/emacsql e956d91f99 095/427: Add -identifier to emacsql-escape., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8aade12994 101/427: Add a unit test for vector update., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql beb0e00b9e 100/427: Rename emacsql--vars-collect., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ee2877dab0 106/427: Clearer error message from escape identifier., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e9b77b4774 112/427: Add a test for CREATE TABLE., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 652847dbf5 110/427: Allow memoization cache to be nil (for development)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ff4c59a2a7 113/427: Fix cl-lib mistake., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f794d4d38f 116/427: Allow for selected columns in :insert-into., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql cefe1ec014 121/427: Add emacsql-sqlite3-unavailable-p., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b2d83c6477 123/427: Fix up ORDER BY, drop :ascending-by., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f52af86b05 124/427: Break apart and organize compilation tests.,
ELPA Syncer <=
- [nongnu] elpa/emacsql 0bff8ccc34 126/427: Fix up README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a362a97c98 136/427: Add README section on foreign keys., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 223db2d397 141/427: Add quote operator., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8951084b40 143/427: Add variable escaping., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 19a65f390e 147/427: Add ignored features section to README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 530b0ad98c 151/427: Allow arbitrary sub-statements., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3012f5b725 154/427: Fix typo., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 301e2ff4b6 175/427: Drop "simple" from helper method names., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 578a71d2d8 157/427: Re-order some definitions to group them., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 935cca89a9 176/427: Add updated information about Windows., ELPA Syncer, 2022/12/13