Skip to content

Commit 3ac3c6f

Browse files
committed
reorder tests so that sessions are intertweened
1 parent 1e24ce2 commit 3ac3c6f

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

ob-sql-session-tests.el

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;;; tests.el --- Tests for ob-sql-session.el -*- lexical-binding: t -*-
22

33
;;; TODO: verify files sql-in and -out-*
4-
4+
;;; tests are according to the the lexicographic order of the function names
55
;;; Code:
66

77
(load-file "./ob-sql.el")
@@ -53,7 +53,6 @@ Assume the source block is at POSITION if non-nil."
5353
(string= lang "sql-session"))))))
5454
(funcall body)))
5555

56-
5756
(defun babel-block-test (setup header code expect)
5857
"Given SETUP function, execute SQL CODE block with HEADER.
5958
Compare the result against EXPECT."
@@ -79,27 +78,27 @@ Compare the result against EXPECT."
7978
#'setup "sql :engine sqlite :session sqlite::tests :results raw"
8079
code expect))
8180

82-
(ert-deftest sqlite-000:test-header ()
81+
(ert-deftest 000-sqlite:test-header ()
8382
"Create table."
8483
(sqlite-test ".headers off" nil))
8584

8685

87-
(ert-deftest sqlite-001:test-create ()
86+
(ert-deftest 001-sqlite:test-create ()
8887
"Create table."
8988
(sqlite-test ".headers off
9089
9190
create table test(one varchar(10), two int);" nil))
9291

93-
(ert-deftest sqlite-002:test-insert ()
92+
(ert-deftest 002-sqlite:test-insert ()
9493
"Insert into table."
9594
(sqlite-test "insert into test values(\'hello\',\'world\');" nil))
9695

97-
(ert-deftest sqlite-003:test-select ()
96+
(ert-deftest 003-sqlite:test-select ()
9897
"Select from table."
9998
(sqlite-test "select * from test;"
10099
"hello|world\n"))
101100

102-
(ert-deftest sqlite-004:test-filter-tabs ()
101+
(ert-deftest 004-sqlite:test-filter-tabs ()
103102
"Insert with tabs."
104103
(sqlite-test "
105104
--create table test(x,y);
@@ -133,12 +132,12 @@ create table test(one varchar(10), two int);" nil))
133132
;; "Parse error: near \".\": syntax error\n .headers on .bail on " ; select 1; \n ^--- error here"
134133
;; )) ;; variations expected between sqlite versions
135134

136-
(ert-deftest sqlite-005a:test-commands ()
135+
(ert-deftest 005a-sqlite:test-commands ()
137136
(sqlite-test
138137
".headers on
139138
" nil))
140139

141-
(ert-deftest sqlite-005b:test-header-on ()
140+
(ert-deftest 005b-sqlite:test-header-on ()
142141
(sqlite-test
143142
".headers on
144143
--create table test(x,y);
@@ -155,15 +154,6 @@ sqlite|3.4
155154
;; additionally, an error after a command can clutter the next shell
156155
;;
157156

158-
(ert-deftest sqlite-006:drop ()
159-
(sqlite-test "Drop table test;" nil))
160-
161-
(ert-deftest sqlite-X:test-close-session()
162-
(with-current-buffer "*SQL: [sqlite::tests]*" ; sqlite:///nil*"
163-
(quit-process nil t)
164-
(let ((kill-buffer-query-functions nil))
165-
(kill-this-buffer))))
166-
167157
(defun pg-test (code expect)
168158
"Test Postgres SQL CODE, with EXPECT 'ed result."
169159
(babel-block-test
@@ -179,15 +169,24 @@ sqlite|3.4
179169
:session pg::tests"
180170
code expect))
181171

182-
(ert-deftest pg-001:test-session-var-set ()
172+
(ert-deftest 006-sqlite:drop ()
173+
(sqlite-test "Drop table test;" nil))
174+
175+
(ert-deftest X-sqlite:test-close-session()
176+
(with-current-buffer "*SQL: [sqlite::tests]*" ; sqlite:///nil*"
177+
(quit-process nil t)
178+
(let ((kill-buffer-query-functions nil))
179+
(kill-this-buffer))))
180+
181+
(ert-deftest 001-pg:test-session-var-set ()
183182
"Select in a table."
184183
(pg-test-session "\\set id10 10 \n \\set id13 13" nil))
185184

186-
(ert-deftest pg-002:test-session-var-read ()
185+
(ert-deftest 002-pg:test-session-var-read ()
187186
"Select in a table."
188187
(pg-test-session "select :id10 as A,:id13 as B;" "a|b\n10|13\n"))
189188

190-
(ert-deftest pg-003:test-create-insert-select ()
189+
(ert-deftest 003-pg:test-create-insert-select ()
191190
"Select in a table."
192191
(pg-test "DROP TABLE if exists publications;
193192
CREATE TABLE publications (id int2, database text);
@@ -197,11 +196,11 @@ CREATE TABLE
197196
INSERT 0 2
198197
database\nHGNC\nFlyBase\n"))
199198

200-
(ert-deftest pg-004:test-expand-variable ()
199+
(ert-deftest 004-pg:test-expand-variable ()
201200
"Expand variable."
202201
(pg-test "select $var as var;" "var\n33\n"))
203202

204-
(ert-deftest pg-X:test-close-session()
203+
(ert-deftest X-pg:test-close-session()
205204
(with-current-buffer "*SQL: [pg::tests]*" ; sqlite:///nil*"
206205
(quit-process nil t)
207206
(let ((kill-buffer-query-functions nil))

0 commit comments

Comments
 (0)