]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/db/tester/tester.factor
factor: trim using lists
[factor.git] / basis / db / tester / tester.factor
index 0952670ec373005c10a635bc98468df540db3c44..0029a0de1e27b52d7238af0fc6c08e831cfdb40b 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008 Slava Pestov, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: concurrency.combinators db.pools db.sqlite db.tuples
-db.types kernel math random threads tools.test db sequences
-io prettyprint db.postgresql accessors io.files.temp
-namespaces fry system math.parser db.queries assocs ;
+USING: accessors assocs concurrency.combinators db db.pools
+db.postgresql db.queries db.sqlite db.tuples db.types
+destructors io.files.temp kernel math math.parser namespaces
+random sequences system threads tools.test ;
 IN: db.tester
 
 : postgresql-test-db-name ( -- string )
@@ -11,23 +11,16 @@ IN: db.tester
     H{ { CHAR: - CHAR: _ } { CHAR: . CHAR: _ } } substitute ;
 
 : postgresql-test-db ( -- postgresql-db )
-    <postgresql-db>
-        "localhost" >>host
-        "postgres" >>username
-        "thepasswordistrust" >>password
-        postgresql-test-db-name >>database ;
+    \ postgresql-db get-global clone postgresql-test-db-name >>database ;
 
 : postgresql-template1-db ( -- postgresql-db )
-    <postgresql-db>
-        "localhost" >>host
-        "postgres" >>username
-        "thepasswordistrust" >>password
-        "template1" >>database ;
+    \ postgresql-db get-global clone "template1" >>database ;
 
 : sqlite-test-db ( -- sqlite-db )
-    "tuples-test.db" temp-file <sqlite-db> ;
+    cpu name>> "tuples-test." ".db" surround
+    temp-file <sqlite-db> ;
 
-! These words leak resources, but are useful for interactivel testing
+! These words leak resources, but are useful for interactive testing
 : set-sqlite-db ( -- )
     sqlite-db db-open db-connection set ;
 
@@ -81,7 +74,7 @@ test-2 "TEST2" {
             test-2 ensure-table
         ] with-db
     ] [
-        10 iota [
+        10 <iota> [
             drop
             10 [
                 dup [
@@ -99,10 +92,12 @@ test-2 "TEST2" {
         ] with-db
     ] [
         <db-pool> [
-            10 iota [
-                10 [
-                    test-1-tuple insert-tuple yield
-                ] times
-            ] parallel-each
-        ] with-pooled-db
+            [
+                10 <iota> [
+                    10 [
+                        test-1-tuple insert-tuple yield
+                    ] times
+                ] parallel-each
+            ] with-pooled-db
+        ] with-disposal
     ] bi ;