1 USING: accessors alien continuations db db.errors db.queries db.postgresql
2 db.private db.tester db.tuples db.types io classes kernel math namespaces
3 prettyprint sequences system tools.test unicode.case ;
4 IN: db.postgresql.tests
6 : nonexistant-db ( -- db )
11 "dont-exist" >>database ;
13 ! Don't leak connections
15 2000 [ [ nonexistant-db [ ] with-db ] ignore-errors ] times
18 ! Ensure the test database exists
19 postgresql-template1-db [
20 postgresql-test-db-name ensure-database
23 ! Triggers a two line error message (ERROR + DETAIL) because two
24 ! connections can't simultaneously use the template1 database.
26 ! postgresql-template1-db [
27 ! postgresql-template1-db [
28 ! "will_never_exist" ensure-database
31 ! ] [ sql-unknown-error? ] must-fail-with
35 [ "drop table person;" sql-command ] ignore-errors
36 "create table person (name varchar(30), country varchar(30));"
39 "insert into person values('John', 'America');" sql-command
40 "insert into person values('Jane', 'New Zealand');" sql-command
47 { "Jane" "New Zealand" }
51 "select * from person" sql-query
58 { "Jane" "New Zealand" }
60 } [ postgresql-test-db [ "select * from person" sql-query ] with-db ] unit-test
65 "insert into person(name, country) values('Jimmy', 'Canada')"
73 { "Jane" "New Zealand" }
76 } [ postgresql-test-db [ "select * from person" sql-query ] with-db ] unit-test
81 "insert into person(name, country) values('Jose', 'Mexico')" sql-command
82 "insert into person(name, country) values('Jose', 'Mexico')" sql-command
90 "select * from person" sql-query length
98 "insert into person(name, country) values('Jose', 'Mexico')"
100 "insert into person(name, country) values('Jose', 'Mexico')"
108 "select * from person" sql-query length