clean up tests a bit, better error handling
parent
511ecaff59
commit
c6e9b55361
|
@ -7,6 +7,17 @@ db.postgresql accessors random math.bitwise
|
||||||
math.ranges strings urls fry db.tuples.private ;
|
math.ranges strings urls fry db.tuples.private ;
|
||||||
IN: db.tuples.tests
|
IN: db.tuples.tests
|
||||||
|
|
||||||
|
: test-sqlite ( quot -- )
|
||||||
|
[ ] swap '[
|
||||||
|
"tuples-test.db" temp-file sqlite-db _ with-db
|
||||||
|
] unit-test ;
|
||||||
|
|
||||||
|
: test-postgresql ( quot -- )
|
||||||
|
[ ] swap '[
|
||||||
|
{ "localhost" "postgres" "foob" "factor-test" }
|
||||||
|
postgresql-db _ with-db
|
||||||
|
] unit-test ;
|
||||||
|
|
||||||
TUPLE: person the-id the-name the-number the-real
|
TUPLE: person the-id the-name the-number the-real
|
||||||
ts date time blob factor-blob url ;
|
ts date time blob factor-blob url ;
|
||||||
|
|
||||||
|
@ -177,7 +188,7 @@ TUPLE: annotation n paste-id summary author mode contents ;
|
||||||
{ "channel" "CHANNEL" TEXT }
|
{ "channel" "CHANNEL" TEXT }
|
||||||
{ "mode" "MODE" TEXT }
|
{ "mode" "MODE" TEXT }
|
||||||
{ "contents" "CONTENTS" TEXT }
|
{ "contents" "CONTENTS" TEXT }
|
||||||
{ "date" "DATE" TIMESTAMP }
|
{ "timestamp" "DATE" TIMESTAMP }
|
||||||
{ "annotations" { +has-many+ annotation } }
|
{ "annotations" { +has-many+ annotation } }
|
||||||
} define-persistent
|
} define-persistent
|
||||||
|
|
||||||
|
@ -191,20 +202,20 @@ TUPLE: annotation n paste-id summary author mode contents ;
|
||||||
{ "contents" "CONTENTS" TEXT }
|
{ "contents" "CONTENTS" TEXT }
|
||||||
} define-persistent ;
|
} define-persistent ;
|
||||||
|
|
||||||
! { "localhost" "postgres" "" "factor-test" } postgresql-db [
|
: test-paste-schema ( -- )
|
||||||
! [ paste drop-table ] [ drop ] recover
|
[ ] [ db-assigned-paste-schema ] unit-test
|
||||||
! [ annotation drop-table ] [ drop ] recover
|
[ ] [ paste ensure-table ] unit-test
|
||||||
! [ paste drop-table ] [ drop ] recover
|
[ ] [ annotation ensure-table ] unit-test
|
||||||
! [ annotation drop-table ] [ drop ] recover
|
[ ] [ annotation drop-table ] unit-test
|
||||||
! [ ] [ paste create-table ] unit-test
|
[ ] [ paste drop-table ] unit-test
|
||||||
! [ ] [ annotation create-table ] unit-test
|
[ ] [ paste create-table ] unit-test
|
||||||
! ] with-db
|
[ ] [ annotation create-table ] unit-test
|
||||||
|
|
||||||
: test-sqlite ( quot -- )
|
;
|
||||||
[ ] swap '[ "tuples-test.db" temp-file sqlite-db _ with-db ] unit-test ;
|
|
||||||
|
! [ test-paste-schema ] test-sqlite
|
||||||
|
! [ test-paste-schema ] test-postgresql
|
||||||
|
|
||||||
: test-postgresql ( quot -- )
|
|
||||||
[ ] swap '[ { "localhost" "postgres" "foob" "factor-test" } postgresql-db _ with-db ] unit-test ;
|
|
||||||
|
|
||||||
: test-repeated-insert
|
: test-repeated-insert
|
||||||
[ ] [ person ensure-table ] unit-test
|
[ ] [ person ensure-table ] unit-test
|
||||||
|
|
|
@ -116,12 +116,15 @@ FACTOR-BLOB NULL URL ;
|
||||||
! PostgreSQL Types:
|
! PostgreSQL Types:
|
||||||
! http://developer.postgresql.org/pgdocs/postgres/datatype.html
|
! http://developer.postgresql.org/pgdocs/postgres/datatype.html
|
||||||
|
|
||||||
ERROR: unknown-modifier ;
|
ERROR: unknown-modifier modifier ;
|
||||||
|
|
||||||
|
: ?at ( obj assoc -- value/obj ? )
|
||||||
|
dupd at* [ [ nip ] [ drop ] if ] keep ;
|
||||||
|
|
||||||
: lookup-modifier ( obj -- string )
|
: lookup-modifier ( obj -- string )
|
||||||
{
|
{
|
||||||
{ [ dup array? ] [ unclip lookup-modifier swap compound ] }
|
{ [ dup array? ] [ unclip lookup-modifier swap compound ] }
|
||||||
[ persistent-table at* [ unknown-modifier ] unless third ]
|
[ persistent-table ?at [ unknown-modifier ] unless third ]
|
||||||
} cond ;
|
} cond ;
|
||||||
|
|
||||||
ERROR: no-sql-type ;
|
ERROR: no-sql-type ;
|
||||||
|
|
Loading…
Reference in New Issue