[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pq bc939f732e 30/63: Setup emacs ert tests
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pq bc939f732e 30/63: Setup emacs ert tests |
Date: |
Mon, 14 Feb 2022 23:24:23 -0500 (EST) |
branch: externals/pq
commit bc939f732ecdff70c6b44c0d24a2bf3d10cec88d
Author: Mario Rodas <marsam@users.noreply.github.com>
Commit: Mario Rodas <marsam@users.noreply.github.com>
Setup emacs ert tests
---
.travis.yml | 13 ++++++++++---
Makefile | 5 +++++
test.el | 44 +++++++++++++++++++++-----------------------
3 files changed, 36 insertions(+), 26 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 5e9e8e8415..bbd20362c7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,8 +11,11 @@ addons:
packages:
- libpq-dev
env:
- - EMACS_VERSION=25.1
- - EMACS_VERSION=snapshot
+ global:
+ - EMACSCONFFLAGS="--with-x-toolkit=no --without-x --without-all
--with-xml2 --with-modules"
+ matrix:
+ - EMACS_VERSION=25.1
+ - EMACS_VERSION=snapshot
matrix:
allow_failures:
- env: EMACS_VERSION=snapshot
@@ -22,5 +25,9 @@ before_install:
- make -f emacs-travis.mk install_emacs
- make -f emacs-travis.mk install_cask
- curl -OL
https://github.com/emacs-mirror/emacs/raw/emacs-25.1/src/emacs-module.h
-script:
+install:
- make
+before_script:
+ - psql -c 'create database travis_ci_test;' -U postgres
+script:
+ - make PG_CONNINFO="user=postgres dbname=travis_ci_test" check
diff --git a/Makefile b/Makefile
index fbea451bb5..474ed3a4c1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,5 @@
+EMACS = emacs
+
PG_CONFIG = pg_config
PGINCLUDEDIR := $(shell $(PG_CONFIG) --pkgincludedir)
@@ -21,3 +23,6 @@ all: $(TARGET)
clean:
$(RM) $(TARGET)
+
+check:
+ $(EMACS) --batch -Q -l ert -l test.el -f ert-run-tests-batch-and-exit
diff --git a/test.el b/test.el
index 91327e7c74..3eafc21736 100644
--- a/test.el
+++ b/test.el
@@ -2,30 +2,28 @@
(file-name-directory (or #$ (expand-file-name
(buffer-file-name)))))
(require 'pq)
+(require 'ert)
-(setq con (pq:connectdb "port=5432 dbname=smith"))
-(pq:query con "select version()")
-;; ("PostgreSQL 9.4.8 on i686-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10)
4.9.2, 32-bit")
-(pq:query con "select 1 union select 2")
-;; (1 2)
-(pq:query con "select 1,2")
-;; ([1 2])
-(pq:query con "select 1,2 union select 3,4")
-;; ([1 2] [3 4])
-(pq:query con "select 'Hello, ' || $1::text" (user-login-name))
-;; ("Hello, andreas")
-(pq:escapeLiteral con "mo'oo\"oo")
-;; "'mo''oo\"oo'"
-(pq:escapeIdentifier con "moo'oo\"oo")
-;; "\"moo'oo\"\"oo\""
-(pq:query con "select true, false, NULL, version()")
+(defvar *conninfo* (or (getenv "PG_CONNINFO") "port=5432 dbname=smith"))
-;; provoke a warning
-(pq:query con "drop table if exists nonexisting_table")
+(ert-deftest pq-query-test ()
+ (let ((conn (pq:connectdb *conninfo*)))
+ (should (equal (pq:query conn "select 1 union select 2") '(1 2)))
+ (should (equal (pq:query conn "select 1,2") '([1 2])))
+ (should (equal (pq:query conn "select 1,2 union select 3,4") '([1 2] [3
4])))
+ (should (equal (pq:query conn "select 'Hello, ' || $1::text"
(user-login-name))
+ (list (concat "Hello, " (user-login-name)))))
-;; Multiple statements
-(pq:query con "select 1; select 2; select 3;")
+ (should (equal (pq:query conn "select true, false, NULL, 42")
+ '([t nil nil 42])))
-(setq con (pq:connectdb))
-(setq con nil)
-(garbage-collect)
+ ;; provoke a warning
+ ;; (pq:query con "drop table if exists nonexisting_table")
+
+ ;; Multiple statements
+ (should (equal (pq:query conn "select 1; select 2; select 3;") '(3)))))
+
+(ert-deftest pq-escape-test ()
+ (let ((conn (pq:connectdb *conninfo*)))
+ (should (equal (pq:escapeLiteral conn "mo'oo\"oo") "'mo''oo\"oo'"))
+ (should (equal (pq:escapeIdentifier conn "moo'oo\"oo")
"\"moo'oo\"\"oo\""))))
- [elpa] externals/pq 56fde7b255 53/63: Improve docstrings., (continued)
- [elpa] externals/pq 56fde7b255 53/63: Improve docstrings., ELPA Syncer, 2022/02/14
- [elpa] externals/pq c9df58b1ac 49/63: Always look up t and nil instead of caching them., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 04c91e8374 63/63: add pq.el and move pq.c -> pq-core.c, ELPA Syncer, 2022/02/14
- [elpa] externals/pq 8cc484c68b 62/63: README: Fix typos., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 272b18abec 43/63: Makefile: Add dependency to check target., ELPA Syncer, 2022/02/14
- [elpa] externals/pq bec131bfae 61/63: README: Elaborate on usage., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 8044537122 23/63: Add testcase that provokes a NOTIFY., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 5566645359 56/63: Fix ERROR-DATA not being a list., ELPA Syncer, 2022/02/14
- [elpa] externals/pq d4c53f6461 55/63: Update README., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 0501c66e6a 51/63: Add testcase for crash reported by "717g301github"., ELPA Syncer, 2022/02/14
- [elpa] externals/pq bc939f732e 30/63: Setup emacs ert tests,
ELPA Syncer <=
- [elpa] externals/pq 555791fef3 18/63: Add GPLv3 license., ELPA Syncer, 2022/02/14
- [elpa] externals/pq d8bca4bbd0 33/63: test: Add case that garbage-collects user-pointers., ELPA Syncer, 2022/02/14
- [elpa] externals/pq e3e74a950a 39/63: Make garbage-collection test more robust., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 8c03aeb2ec 15/63: Fix nargs compatible pointer type, ELPA Syncer, 2022/02/14
- [elpa] externals/pq cbdff81a90 47/63: Make docstring punctuation consistent., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 5486071191 50/63: travis-ci: Also test with Emacs 26., ELPA Syncer, 2022/02/14
- [elpa] externals/pq ae8f1a33ac 45/63: Make PQreset available as pq:reset., ELPA Syncer, 2022/02/14
- [elpa] externals/pq fbc92e891d 59/63: README: Fix typo., ELPA Syncer, 2022/02/14
- [elpa] externals/pq c653a8b1ee 54/63: Remove unused macro., ELPA Syncer, 2022/02/14