You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2019/07/28 13:47:51 UTC

[couchdb] 04/04: Modernize the sync_security test setup/teardown

This is an automated email from the ASF dual-hosted git repository.

kocolosk pushed a commit to branch jenkins-fix-eunit-timeouts
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 265b1ca8f70493b1a0c682a994dc2be7f70614aa
Author: Adam Kocoloski <ko...@apache.org>
AuthorDate: Sun Jul 28 09:45:27 2019 -0400

    Modernize the sync_security test setup/teardown
    
    This test actually doesn't do much real work, but I think what was
    happening is that the setup and teardown time was being charged to the
    test itself. I've refactored it to use a more modern scaffolding
    following some of our more recent additions to the test suite, but have
    left the timeout at the default to test this hypothesis.
---
 src/mem3/test/mem3_sync_security_test.erl | 48 ++++++++++++++++++++++---------
 1 file changed, 35 insertions(+), 13 deletions(-)

diff --git a/src/mem3/test/mem3_sync_security_test.erl b/src/mem3/test/mem3_sync_security_test.erl
index 4e06dd8..e67a720 100644
--- a/src/mem3/test/mem3_sync_security_test.erl
+++ b/src/mem3/test/mem3_sync_security_test.erl
@@ -17,16 +17,38 @@
 -include("mem3.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
-go_test() ->
-    Ctx = test_util:start_couch([fabric, mem3]),
-    try
-        ok = meck:new(fabric, [passthrough]),
-        meck:expect(fabric, all_dbs, fun() ->
-            {ok, [<<"NoExistDb1">>, <<"NoExistDb2">>]}
-        end),
-        Result = mem3_sync_security:go(),
-        ?assertEqual(ok, Result)
-    after
-        meck:unload(),
-        test_util:stop_couch(Ctx)
-    end.
+-define(TIMEOUT, 5). % seconds
+
+go_test_() ->
+    {
+        "security property sync test",
+        {
+            setup,
+            fun start_couch/0, fun stop_couch/1,
+            {
+                foreach,
+                fun setup/0, fun teardown/1,
+                [
+                    fun sync_security_ok/1
+                ]
+            }
+        }
+    }.
+
+start_couch() ->
+    test_util:start_couch([fabric, mem3]).
+
+stop_couch(Ctx) ->
+    test_util:stop_couch(Ctx).
+
+setup() ->
+    ok = meck:new(fabric, [passthrough]),
+    meck:expect(fabric, all_dbs, fun() ->
+        {ok, [<<"NoExistDb1">>, <<"NoExistDb2">>]}
+    end).
+
+teardown(_) ->
+    meck:unload().
+
+sync_security_ok(_) ->
+    {timeout, ?TIMEOUT, ?_assertEqual(ok, mem3_sync_security:go())}.