From e6de81706ba10677921f115fcbcaac05a9c02305 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 30 Sep 2010 20:35:35 -0700 Subject: [PATCH] webapps.mason: fix counter and dashboard actions, add more comprehensive tests --- extra/webapps/mason/backend/backend-tests.factor | 12 ++++++++---- extra/webapps/mason/backend/backend.factor | 6 ++---- extra/webapps/mason/dashboard/dashboard.factor | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/extra/webapps/mason/backend/backend-tests.factor b/extra/webapps/mason/backend/backend-tests.factor index 000ed4024e..b36fc24a74 100644 --- a/extra/webapps/mason/backend/backend-tests.factor +++ b/extra/webapps/mason/backend/backend-tests.factor @@ -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 [ - 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 diff --git a/extra/webapps/mason/backend/backend.factor b/extra/webapps/mason/backend/backend.factor index fa01b3a2c6..217e6b8a1a 100644 --- a/extra/webapps/mason/backend/backend.factor +++ b/extra/webapps/mason/backend/backend.factor @@ -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 diff --git a/extra/webapps/mason/dashboard/dashboard.factor b/extra/webapps/mason/dashboard/dashboard.factor index 7a98bc881f..e8f97771dd 100644 --- a/extra/webapps/mason/dashboard/dashboard.factor +++ b/extra/webapps/mason/dashboard/dashboard.factor @@ -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