remove math.blas.syntax and merge parsing words into math.blas.vectors/matrices
[factor/jcg.git] / basis / db / sqlite / sqlite-tests.factor
blob6fb1cd19adccb262b943a4bbad49ccfaa90135e5
1 USING: io io.files io.files.temp io.directories io.launcher
2 kernel namespaces prettyprint tools.test db.sqlite db sequences
3 continuations db.types db.tuples unicode.case ;
4 IN: db.sqlite.tests
6 : db-path ( -- path ) "test.db" temp-file ;
7 : test.db ( -- sqlite-db ) db-path <sqlite-db> ;
9 [ ] [ [ db-path delete-file ] ignore-errors ] unit-test
11 [ ] [
12     test.db [
13         "create table person (name varchar(30), country varchar(30))" sql-command
14         "insert into person values('John', 'America')" sql-command
15         "insert into person values('Jane', 'New Zealand')" sql-command
16     ] with-db
17 ] unit-test
20 [ { { "John" "America" } { "Jane" "New Zealand" } } ] [
21     test.db [
22         "select * from person" sql-query
23     ] with-db
24 ] unit-test
26 [ { { "1" "John" "America" } { "2" "Jane" "New Zealand" } } ]
27 [ test.db [ "select rowid, * from person" sql-query ] with-db ] unit-test
29 [ ] [
30     test.db [
31         "insert into person(name, country) values('Jimmy', 'Canada')"
32         sql-command
33     ] with-db
34 ] unit-test
37     {
38         { "1" "John" "America" }
39         { "2" "Jane" "New Zealand" }
40         { "3" "Jimmy" "Canada" }
41     }
42 ] [ test.db [ "select rowid, * from person" sql-query ] with-db ] unit-test
45     test.db [
46         [
47             "insert into person(name, country) values('Jose', 'Mexico')" sql-command
48             "insert into person(name, country) values('Jose', 'Mexico')" sql-command
49             "oops" throw
50         ] with-transaction
51     ] with-db
52 ] must-fail
54 [ 3 ] [
55     test.db [
56         "select * from person" sql-query length
57     ] with-db
58 ] unit-test
60 [ ] [
61     test.db [
62         [
63             "insert into person(name, country) values('Jose', 'Mexico')"
64             sql-command
65             "insert into person(name, country) values('Jose', 'Mexico')"
66             sql-command
67         ] with-transaction
68     ] with-db
69 ] unit-test
71 [ 5 ] [
72     test.db [
73         "select * from person" sql-query length
74     ] with-db
75 ] unit-test