2008-02-01 18:43:44 -05:00
|
|
|
USING: io io.files io.launcher kernel namespaces
|
2008-02-04 14:32:27 -05:00
|
|
|
prettyprint tools.test db.sqlite db sequences
|
2008-02-20 12:30:48 -05:00
|
|
|
continuations db.types db.tuples unicode.case ;
|
2008-03-01 17:00:45 -05:00
|
|
|
IN: db.sqlite.tests
|
2008-02-01 18:43:44 -05:00
|
|
|
|
2008-03-06 04:03:07 -05:00
|
|
|
: db-path "test.db" temp-file ;
|
2008-10-02 17:02:31 -04:00
|
|
|
: test.db db-path <sqlite-db> ;
|
2008-02-01 18:43:44 -05:00
|
|
|
|
2008-03-05 14:51:31 -05:00
|
|
|
[ ] [ [ db-path delete-file ] ignore-errors ] unit-test
|
2008-02-01 18:43:44 -05:00
|
|
|
|
2008-02-04 14:57:22 -05:00
|
|
|
[ ] [
|
|
|
|
test.db [
|
|
|
|
"create table person (name varchar(30), country varchar(30))" sql-command
|
|
|
|
"insert into person values('John', 'America')" sql-command
|
|
|
|
"insert into person values('Jane', 'New Zealand')" sql-command
|
2008-03-05 14:51:31 -05:00
|
|
|
] with-db
|
2008-02-04 14:57:22 -05:00
|
|
|
] unit-test
|
2008-02-01 18:43:44 -05:00
|
|
|
|
|
|
|
|
2008-02-04 14:57:22 -05:00
|
|
|
[ { { "John" "America" } { "Jane" "New Zealand" } } ] [
|
2008-02-03 16:06:31 -05:00
|
|
|
test.db [
|
2008-02-03 00:28:33 -05:00
|
|
|
"select * from person" sql-query
|
2008-03-05 14:51:31 -05:00
|
|
|
] with-db
|
2008-02-01 18:43:44 -05:00
|
|
|
] unit-test
|
|
|
|
|
2008-02-04 14:57:22 -05:00
|
|
|
[ { { "1" "John" "America" } { "2" "Jane" "New Zealand" } } ]
|
2008-03-05 14:51:31 -05:00
|
|
|
[ test.db [ "select rowid, * from person" sql-query ] with-db ] unit-test
|
2008-02-01 18:43:44 -05:00
|
|
|
|
2008-02-04 14:57:22 -05:00
|
|
|
[ ] [
|
2008-02-03 16:06:31 -05:00
|
|
|
test.db [
|
2008-02-01 18:43:44 -05:00
|
|
|
"insert into person(name, country) values('Jimmy', 'Canada')"
|
2008-02-03 00:28:33 -05:00
|
|
|
sql-command
|
2008-03-05 14:51:31 -05:00
|
|
|
] with-db
|
2008-02-01 18:43:44 -05:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[
|
|
|
|
{
|
|
|
|
{ "1" "John" "America" }
|
|
|
|
{ "2" "Jane" "New Zealand" }
|
|
|
|
{ "3" "Jimmy" "Canada" }
|
|
|
|
}
|
2008-03-05 14:51:31 -05:00
|
|
|
] [ test.db [ "select rowid, * from person" sql-query ] with-db ] unit-test
|
2008-02-01 18:43:44 -05:00
|
|
|
|
|
|
|
[
|
2008-02-03 16:06:31 -05:00
|
|
|
test.db [
|
2008-02-01 18:43:44 -05:00
|
|
|
[
|
2008-02-03 00:28:33 -05:00
|
|
|
"insert into person(name, country) values('Jose', 'Mexico')" sql-command
|
|
|
|
"insert into person(name, country) values('Jose', 'Mexico')" sql-command
|
2008-02-01 18:43:44 -05:00
|
|
|
"oops" throw
|
|
|
|
] with-transaction
|
2008-03-05 14:51:31 -05:00
|
|
|
] with-db
|
2008-02-06 14:47:19 -05:00
|
|
|
] must-fail
|
2008-02-01 18:43:44 -05:00
|
|
|
|
|
|
|
[ 3 ] [
|
2008-02-03 16:06:31 -05:00
|
|
|
test.db [
|
2008-02-03 00:28:33 -05:00
|
|
|
"select * from person" sql-query length
|
2008-03-05 14:51:31 -05:00
|
|
|
] with-db
|
2008-02-01 18:43:44 -05:00
|
|
|
] unit-test
|
|
|
|
|
2008-09-02 23:50:46 -04:00
|
|
|
[ ] [
|
2008-02-03 16:06:31 -05:00
|
|
|
test.db [
|
2008-02-01 18:43:44 -05:00
|
|
|
[
|
2008-02-03 00:28:33 -05:00
|
|
|
"insert into person(name, country) values('Jose', 'Mexico')"
|
|
|
|
sql-command
|
|
|
|
"insert into person(name, country) values('Jose', 'Mexico')"
|
|
|
|
sql-command
|
2008-02-01 18:43:44 -05:00
|
|
|
] with-transaction
|
2008-03-05 14:51:31 -05:00
|
|
|
] with-db
|
2008-02-01 18:43:44 -05:00
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ 5 ] [
|
2008-02-03 16:06:31 -05:00
|
|
|
test.db [
|
2008-02-03 00:28:33 -05:00
|
|
|
"select * from person" sql-query length
|
2008-03-05 14:51:31 -05:00
|
|
|
] with-db
|
2008-02-20 12:30:48 -05:00
|
|
|
] unit-test
|