Skip to content

Commit

Permalink
TEST: sqlite scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jun 4, 2024
1 parent 4987247 commit 2268daf
Show file tree
Hide file tree
Showing 6 changed files with 287 additions and 295 deletions.
15 changes: 3 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ jobs:
- name: Install Rebol for extension test
uses: oldes/install-rebol@v3.17.0

- name: Test SQLite raw extension
- name: Test SQLite extension
run: ./rebol3 ci-test.r3

- name: Test SQLite scheme
run: ./rebol3 sqlite-scheme.r3

###############################################################################
# Collecting build artifacts...
- uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -77,12 +74,9 @@ jobs:
- name: Install Rebol for extension test
uses: oldes/install-rebol@v3.17.0

- name: Test SQLite raw extension
- name: Test SQLite extension
run: ./rebol3 ci-test.r3

- name: Test SQLite scheme
run: ./rebol3 sqlite-scheme.r3

- name: Compress 64bit Rebol SQLite extension
run: gzip -9 ./sqlite-linux-x64.rebx

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

- name: Test SQLite raw extension
- name: Test SQLite extension
run: ./rebol3 ci-test.r3

- name: Test SQLite scheme
run: ./rebol3 sqlite-scheme.r3

- name: Compress 64bit Rebol SQLite extension
run: gzip -9 ./sqlite-macos-x64.rebx

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
!README.md
!LICENSE
!ci-test.r3
!sqlite-scheme.r3
!sqlite-scheme.reb
121 changes: 121 additions & 0 deletions ci-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,126 @@ COMMIT;}
print info
print "SQLite tests done."
]


;------------------------------------------------------------------------------------------------
print-horizontal-line
print as-yellow "SQLITE SCHEME TESTS"
print-horizontal-line

import %sqlite-scheme.reb

if exists? %chinook.db [
db: open/new sqlite:chinook.db

probe read insert db {SELECT
InvoiceId,
BillingAddress,
date(InvoiceDate) InvoiceDate,
Total
FROM
invoices
WHERE
InvoiceDate NOT BETWEEN '2009-01-03' AND '2013-12-01'
ORDER BY
InvoiceDate;
}
]

;open sqlite:new.db ;; would throw an error, if the file ./new.db does not exists
;open sqlite:/home/oldes/new.db ;; used full path to the DB file

print-horizontal-line
prin as-yellow "Testing an error message, when trying to open a database using not existing dir."
print try [open/new sqlite:not-exists/dir]

;; Create a new DB file in the current dir, if it does not exists, and open it
db: open/new sqlite:new.db

;; Allow verbose SQLite traces...
modify db 'trace-level 3 ;= SQLITE_TRACE_STMT or SQLITE_TRACE_PROFILE

;; Execute multiple queries at once...
write db {
BEGIN TRANSACTION;
/* delete any tables used in the test */
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS Cars;
DROP TABLE IF EXISTS Contacts;
/* ---------------------------------- */
CREATE TABLE Cars(Id INTEGER PRIMARY KEY, Name TEXT, Price INTEGER);
INSERT INTO "Cars" VALUES(1,'Audi',52642);
INSERT INTO "Cars" VALUES(2,'Mercedes',57127);
INSERT INTO "Cars" VALUES(3,'Skoda',9000);
INSERT INTO "Cars" VALUES(4,'Volvo',29000);
INSERT INTO "Cars" VALUES(5,'Bentley',350000);
INSERT INTO "Cars" VALUES(6,'Citroen',21000);
INSERT INTO "Cars" VALUES(7,'Hummer',41400);
INSERT INTO "Cars" VALUES(NULL,'Audi',52642);
INSERT INTO "Cars" VALUES(NULL,'Mercedes',57127);
INSERT INTO "Cars" VALUES(NULL,'Skoda',9000);
INSERT INTO "Cars" VALUES(NULL,'Volvo',29000);
INSERT INTO "Cars" VALUES(NULL,'Bentley',350000);
INSERT INTO "Cars" VALUES(NULL,'Citroen',21000);
INSERT INTO "Cars" VALUES(NULL,'Hummer',41400);
INSERT INTO "Cars" VALUES(NULL,'Audi',52642);
INSERT INTO "Cars" VALUES(NULL,'Mercedes',57127);
INSERT INTO "Cars" VALUES(NULL,'Skoda',9000);
INSERT INTO "Cars" VALUES(NULL,'Volvo',29000);
INSERT INTO "Cars" VALUES(NULL,'Bentley',350000);
INSERT INTO "Cars" VALUES(NULL,'Citroen',21000);
INSERT INTO "Cars" VALUES(NULL,'Hummer',41400);
INSERT INTO "Cars" VALUES(NULL,'Audi',52642);
INSERT INTO "Cars" VALUES(NULL,'Mercedes',57127);
INSERT INTO "Cars" VALUES(NULL,'Skoda',9000);
INSERT INTO "Cars" VALUES(NULL,'Volvo',29000);
INSERT INTO "Cars" VALUES(NULL,'Bentley',350000);
INSERT INTO "Cars" VALUES(NULL,'Citroen',21000);
INSERT INTO "Cars" VALUES(NULL,'Hummer',41400);
INSERT INTO "Cars" VALUES(NULL,'Audi',52642);
INSERT INTO "Cars" VALUES(NULL,'Mercedes',57127);
INSERT INTO "Cars" VALUES(NULL,'Skoda',9000);
INSERT INTO "Cars" VALUES(NULL,'Volvo',29000);
INSERT INTO "Cars" VALUES(NULL,'Bentley',350000);
INSERT INTO "Cars" VALUES(NULL,'Citroen',21000);
INSERT INTO "Cars" VALUES(NULL,'Hummer',41400);
CREATE TABLE Contacts (
email TEXT PRIMARY KEY,
first_name TEXT NOT NULL,
last_name TEXT NOT NULL
);
INSERT INTO "Contacts" VALUES('oceane.pacome@corporate.com', 'Océane', 'Pacôme');
INSERT INTO "Contacts" VALUES('Oldes@corporate.com','Oldes', 'Huhuman');
COMMIT;
}

print-horizontal-line
prin as-yellow "Testing an error message of the invalid query."
print try [insert db "INVALID_QUERY"]

print-horizontal-line

insert db "SELECT * FROM Cars" ;; Prepares a statement
print as-yellow "Resolving 10 rows one by one..."
loop 10 [probe take db]
print as-yellow "Resolving 5 rows at once..."
probe read/part db 5
print as-yellow "Resolving the rest of rows..."
probe read db

print-horizontal-line
print as-yellow "Resolving 4 random hexadecimal blobs"
insert db "SELECT hex(randomblob(16)), hex(randomblob(16)), hex(randomblob(16)), hex(randomblob(16))"
probe read db

print-horizontal-line
print as-yellow "Resolving all data using PICK action"
probe pick db "SELECT * FROM Contacts"


print as-yellow "DONE"

;quit

Loading

0 comments on commit 2268daf

Please sign in to comment.