Skip to content

Commit

Permalink
db.postgresql: ensure that 2 line error messages are handled
Browse files Browse the repository at this point in the history
  • Loading branch information
bjourne committed Sep 30, 2014
1 parent 97b3ee3 commit 655797f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
20 changes: 16 additions & 4 deletions basis/db/postgresql/postgresql-tests.factor
@@ -1,6 +1,6 @@
USING: accessors alien continuations db db.queries db.postgresql db.private
db.tester db.tuples db.types io classes kernel math namespaces prettyprint
sequences system tools.test unicode.case ;
USING: accessors alien continuations db db.errors db.queries db.postgresql
db.private db.tester db.tuples db.types io classes kernel math namespaces
prettyprint sequences system tools.test unicode.case ;
IN: db.postgresql.tests

: nonexistant-db ( -- db )
Expand All @@ -16,7 +16,19 @@ IN: db.postgresql.tests
] unit-test

! Ensure the test database exists
[ ] [ postgresql-test-db [ ] with-db ] unit-test
postgresql-template1-db [
postgresql-test-db-name ensure-database
] with-db

! Triggers a two line error message (ERROR + DETAIL) because two
! connections can't simultaneously use the template1 database.
[
postgresql-template1-db [
postgresql-template1-db [
"will_never_exist" ensure-database
] with-db
] with-db
] [ sql-unknown-error? ] must-fail-with

[ ] [
postgresql-test-db [
Expand Down
2 changes: 1 addition & 1 deletion basis/db/postgresql/postgresql.factor
Expand Up @@ -284,10 +284,10 @@ M: postgresql-db-connection compound ( string object -- string' )
M: postgresql-db-connection parse-db-error
"\n" split dup length {
{ 1 [ first parse-postgresql-sql-error ] }
{ 2 [ concat parse-postgresql-sql-error ] }
{ 3 [
first3
[ parse-postgresql-sql-error ] 2dip
postgresql-location >>location
] }
} case ;

0 comments on commit 655797f

Please sign in to comment.