Skip to content

Commit 2268daf

Browse files
committed
TEST: sqlite scheme
1 parent 4987247 commit 2268daf

File tree

6 files changed

+287
-295
lines changed

6 files changed

+287
-295
lines changed

.github/workflows/main.yml

+3-12
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,9 @@ jobs:
3131
- name: Install Rebol for extension test
3232
uses: oldes/install-rebol@v3.17.0
3333

34-
- name: Test SQLite raw extension
34+
- name: Test SQLite extension
3535
run: ./rebol3 ci-test.r3
3636

37-
- name: Test SQLite scheme
38-
run: ./rebol3 sqlite-scheme.r3
39-
4037
###############################################################################
4138
# Collecting build artifacts...
4239
- uses: actions/upload-artifact@v3
@@ -77,12 +74,9 @@ jobs:
7774
- name: Install Rebol for extension test
7875
uses: oldes/install-rebol@v3.17.0
7976

80-
- name: Test SQLite raw extension
77+
- name: Test SQLite extension
8178
run: ./rebol3 ci-test.r3
8279

83-
- name: Test SQLite scheme
84-
run: ./rebol3 sqlite-scheme.r3
85-
8680
- name: Compress 64bit Rebol SQLite extension
8781
run: gzip -9 ./sqlite-linux-x64.rebx
8882

@@ -109,12 +103,9 @@ jobs:
109103
- name: Install Rebol for extension test
110104
uses: oldes/install-rebol@v3.17.0
111105

112-
- name: Test SQLite raw extension
106+
- name: Test SQLite extension
113107
run: ./rebol3 ci-test.r3
114108

115-
- name: Test SQLite scheme
116-
run: ./rebol3 sqlite-scheme.r3
117-
118109
- name: Compress 64bit Rebol SQLite extension
119110
run: gzip -9 ./sqlite-macos-x64.rebx
120111

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
!README.md
1010
!LICENSE
1111
!ci-test.r3
12-
!sqlite-scheme.r3
12+
!sqlite-scheme.reb

ci-test.r3

+121
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,126 @@ COMMIT;}
187187
print info
188188
print "SQLite tests done."
189189
]
190+
191+
192+
;------------------------------------------------------------------------------------------------
193+
print-horizontal-line
194+
print as-yellow "SQLITE SCHEME TESTS"
195+
print-horizontal-line
196+
197+
import %sqlite-scheme.reb
198+
199+
if exists? %chinook.db [
200+
db: open/new sqlite:chinook.db
201+
202+
probe read insert db {SELECT
203+
InvoiceId,
204+
BillingAddress,
205+
date(InvoiceDate) InvoiceDate,
206+
Total
207+
FROM
208+
invoices
209+
WHERE
210+
InvoiceDate NOT BETWEEN '2009-01-03' AND '2013-12-01'
211+
ORDER BY
212+
InvoiceDate;
213+
}
214+
]
215+
216+
;open sqlite:new.db ;; would throw an error, if the file ./new.db does not exists
217+
;open sqlite:/home/oldes/new.db ;; used full path to the DB file
218+
219+
print-horizontal-line
220+
prin as-yellow "Testing an error message, when trying to open a database using not existing dir."
221+
print try [open/new sqlite:not-exists/dir]
222+
223+
;; Create a new DB file in the current dir, if it does not exists, and open it
224+
db: open/new sqlite:new.db
225+
226+
;; Allow verbose SQLite traces...
227+
modify db 'trace-level 3 ;= SQLITE_TRACE_STMT or SQLITE_TRACE_PROFILE
228+
229+
;; Execute multiple queries at once...
230+
write db {
231+
BEGIN TRANSACTION;
232+
/* delete any tables used in the test */
233+
DROP TABLE IF EXISTS t1;
234+
DROP TABLE IF EXISTS t2;
235+
DROP TABLE IF EXISTS Cars;
236+
DROP TABLE IF EXISTS Contacts;
237+
/* ---------------------------------- */
238+
CREATE TABLE Cars(Id INTEGER PRIMARY KEY, Name TEXT, Price INTEGER);
239+
INSERT INTO "Cars" VALUES(1,'Audi',52642);
240+
INSERT INTO "Cars" VALUES(2,'Mercedes',57127);
241+
INSERT INTO "Cars" VALUES(3,'Skoda',9000);
242+
INSERT INTO "Cars" VALUES(4,'Volvo',29000);
243+
INSERT INTO "Cars" VALUES(5,'Bentley',350000);
244+
INSERT INTO "Cars" VALUES(6,'Citroen',21000);
245+
INSERT INTO "Cars" VALUES(7,'Hummer',41400);
246+
INSERT INTO "Cars" VALUES(NULL,'Audi',52642);
247+
INSERT INTO "Cars" VALUES(NULL,'Mercedes',57127);
248+
INSERT INTO "Cars" VALUES(NULL,'Skoda',9000);
249+
INSERT INTO "Cars" VALUES(NULL,'Volvo',29000);
250+
INSERT INTO "Cars" VALUES(NULL,'Bentley',350000);
251+
INSERT INTO "Cars" VALUES(NULL,'Citroen',21000);
252+
INSERT INTO "Cars" VALUES(NULL,'Hummer',41400);
253+
INSERT INTO "Cars" VALUES(NULL,'Audi',52642);
254+
INSERT INTO "Cars" VALUES(NULL,'Mercedes',57127);
255+
INSERT INTO "Cars" VALUES(NULL,'Skoda',9000);
256+
INSERT INTO "Cars" VALUES(NULL,'Volvo',29000);
257+
INSERT INTO "Cars" VALUES(NULL,'Bentley',350000);
258+
INSERT INTO "Cars" VALUES(NULL,'Citroen',21000);
259+
INSERT INTO "Cars" VALUES(NULL,'Hummer',41400);
260+
INSERT INTO "Cars" VALUES(NULL,'Audi',52642);
261+
INSERT INTO "Cars" VALUES(NULL,'Mercedes',57127);
262+
INSERT INTO "Cars" VALUES(NULL,'Skoda',9000);
263+
INSERT INTO "Cars" VALUES(NULL,'Volvo',29000);
264+
INSERT INTO "Cars" VALUES(NULL,'Bentley',350000);
265+
INSERT INTO "Cars" VALUES(NULL,'Citroen',21000);
266+
INSERT INTO "Cars" VALUES(NULL,'Hummer',41400);
267+
INSERT INTO "Cars" VALUES(NULL,'Audi',52642);
268+
INSERT INTO "Cars" VALUES(NULL,'Mercedes',57127);
269+
INSERT INTO "Cars" VALUES(NULL,'Skoda',9000);
270+
INSERT INTO "Cars" VALUES(NULL,'Volvo',29000);
271+
INSERT INTO "Cars" VALUES(NULL,'Bentley',350000);
272+
INSERT INTO "Cars" VALUES(NULL,'Citroen',21000);
273+
INSERT INTO "Cars" VALUES(NULL,'Hummer',41400);
274+
275+
CREATE TABLE Contacts (
276+
email TEXT PRIMARY KEY,
277+
first_name TEXT NOT NULL,
278+
last_name TEXT NOT NULL
279+
);
280+
INSERT INTO "Contacts" VALUES('oceane.pacome@corporate.com', 'Océane', 'Pacôme');
281+
INSERT INTO "Contacts" VALUES('Oldes@corporate.com','Oldes', 'Huhuman');
282+
COMMIT;
283+
}
284+
285+
print-horizontal-line
286+
prin as-yellow "Testing an error message of the invalid query."
287+
print try [insert db "INVALID_QUERY"]
288+
289+
print-horizontal-line
290+
291+
insert db "SELECT * FROM Cars" ;; Prepares a statement
292+
print as-yellow "Resolving 10 rows one by one..."
293+
loop 10 [probe take db]
294+
print as-yellow "Resolving 5 rows at once..."
295+
probe read/part db 5
296+
print as-yellow "Resolving the rest of rows..."
297+
probe read db
298+
299+
print-horizontal-line
300+
print as-yellow "Resolving 4 random hexadecimal blobs"
301+
insert db "SELECT hex(randomblob(16)), hex(randomblob(16)), hex(randomblob(16)), hex(randomblob(16))"
302+
probe read db
303+
304+
print-horizontal-line
305+
print as-yellow "Resolving all data using PICK action"
306+
probe pick db "SELECT * FROM Contacts"
307+
308+
309+
print as-yellow "DONE"
310+
190311
;quit
191312

0 commit comments

Comments
 (0)