]> gitweb.factorcode.org Git - factor.git/commitdiff
webapps.mason: fix counter and dashboard actions, add more comprehensive tests
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 1 Oct 2010 03:35:35 +0000 (20:35 -0700)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 1 Oct 2010 03:49:03 +0000 (20:49 -0700)
extra/webapps/mason/backend/backend-tests.factor
extra/webapps/mason/backend/backend.factor
extra/webapps/mason/dashboard/dashboard.factor

index 000ed4024ed5d0af6ea3823cc6945e6a9344f84c..b36fc24a74b75617d98ebf8cb2a9f1a59ebbaedb 100644 (file)
@@ -5,11 +5,15 @@ IN: webapps.mason.backend.tests
 [ "test.db" temp-file delete-file ] ignore-errors
 
 [ 0 1 2 ] [
+    ! Do it in a with-transaction to simulate semantics of
+    ! with-mason-db
     "test.db" temp-file <sqlite-db> [
-        init-mason-db
+        [
+            init-mason-db
 
-        counter-value
-        increment-counter-value
-        increment-counter-value
+            counter-value
+            increment-counter-value
+            increment-counter-value
+        ] with-transaction
     ] with-db
 ] unit-test
index fa01b3a2c6a0709e19fa6d2172061e6e594b070e..217e6b8a1a0935761e7cd0e18b5fdf0dc3111582 100644 (file)
@@ -58,12 +58,10 @@ counter "COUNTER" {
     [ counter new dup insert-tuple ] unless* ;
 
 : counter-value ( -- n )
-    [ counter-tuple value>> 0 or ] with-transaction ;
+    counter-tuple value>> 0 or ;
 
 : increment-counter-value ( -- n )
-    [
-        counter-tuple [ 0 or 1 + dup ] change-value update-tuple
-    ] with-transaction ;
+    counter-tuple [ 0 or 1 + dup ] change-value update-tuple ;
 
 : funny-builders ( -- crashed broken )
     builder new select-tuples
index 7a98bc881fe2a02da79f49cd9b34231dc42f20f9..e8f97771dd76b689803e5209da44343c9b6de719 100644 (file)
@@ -18,7 +18,7 @@ IN: webapps.mason.downloads
     [
         [
             funny-builders
-            [ builder-list ] tri@
+            [ builder-list ] bi@
             [ "crashed" set-value ]
             [ "broken" set-value ] bi*
         ] with-mason-db