couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [couchdb] 01/06: Normalize fabric2 test suite
Date Wed, 04 Dec 2019 19:18:05 GMT
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch prototype/fdb-layer-get-dbs-info
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit b0a2527b41fb3b452834a188ffb270c46bc4badf
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
AuthorDate: Wed Dec 4 13:13:26 2019 -0600

    Normalize fabric2 test suite
    
    This change ensures that all test names are visible and follows a single
    unified pattern for each test module.
---
 src/fabric/test/fabric2_changes_fold_tests.erl     | 23 ++++--
 src/fabric/test/fabric2_db_crud_tests.erl          | 20 +++--
 src/fabric/test/fabric2_db_misc_tests.erl          | 26 +++---
 src/fabric/test/fabric2_db_security_tests.erl      | 40 ++++++----
 src/fabric/test/fabric2_dir_prefix_tests.erl       | 25 +++---
 src/fabric/test/fabric2_doc_count_tests.erl        | 19 +++--
 src/fabric/test/fabric2_doc_crud_tests.erl         | 93 ++++++++++++----------
 src/fabric/test/fabric2_fdb_tx_retry_tests.erl     | 52 ++++++------
 src/fabric/test/fabric2_node_types_tests.erl       | 23 +++---
 src/fabric/test/fabric2_rev_stemming.erl           | 31 +++++---
 src/fabric/test/fabric2_trace_db_create_tests.erl  | 17 +++-
 src/fabric/test/fabric2_trace_db_delete_tests.erl  | 15 +++-
 src/fabric/test/fabric2_trace_db_open_tests.erl    | 15 +++-
 src/fabric/test/fabric2_trace_doc_create_tests.erl | 20 +++--
 14 files changed, 259 insertions(+), 160 deletions(-)

diff --git a/src/fabric/test/fabric2_changes_fold_tests.erl b/src/fabric/test/fabric2_changes_fold_tests.erl
index 892b448..ba0fb4d 100644
--- a/src/fabric/test/fabric2_changes_fold_tests.erl
+++ b/src/fabric/test/fabric2_changes_fold_tests.erl
@@ -18,6 +18,7 @@
 -include_lib("eunit/include/eunit.hrl").
 
 
+-define(TDEF(Name), {atom_to_list(Name), fun Name/1}).
 -define(DOC_COUNT, 25).
 
 
@@ -28,14 +29,14 @@ changes_fold_test_() ->
             setup,
             fun setup/0,
             fun cleanup/1,
-            {with, [
-                fun fold_changes_basic/1,
-                fun fold_changes_since_now/1,
-                fun fold_changes_since_seq/1,
-                fun fold_changes_basic_rev/1,
-                fun fold_changes_since_now_rev/1,
-                fun fold_changes_since_seq_rev/1
-            ]}
+            with([
+                ?TDEF(fold_changes_basic),
+                ?TDEF(fold_changes_since_now),
+                ?TDEF(fold_changes_since_seq),
+                ?TDEF(fold_changes_basic_rev),
+                ?TDEF(fold_changes_since_now_rev),
+                ?TDEF(fold_changes_since_seq_rev)
+            ])
         }
     }.
 
@@ -66,6 +67,12 @@ cleanup({Db, _DocIdRevs, Ctx}) ->
     test_util:stop_couch(Ctx).
 
 
+with(Tests) ->
+    fun(ArgsTuple) ->
+        [{Name, ?_test(Fun(ArgsTuple))} || {Name, Fun} <- Tests]
+    end.
+
+
 fold_changes_basic({Db, DocRows, _}) ->
     {ok, Rows} = fabric2_db:fold_changes(Db, 0, fun fold_fun/2, []),
     ?assertEqual(lists:reverse(DocRows), Rows).
diff --git a/src/fabric/test/fabric2_db_crud_tests.erl b/src/fabric/test/fabric2_db_crud_tests.erl
index 24deeb2..3082f0b 100644
--- a/src/fabric/test/fabric2_db_crud_tests.erl
+++ b/src/fabric/test/fabric2_db_crud_tests.erl
@@ -17,7 +17,7 @@
 -include_lib("eunit/include/eunit.hrl").
 
 
--define(TDEF(A), {atom_to_list(A), fun A/0}).
+-define(TDEF(A), {atom_to_list(A), fun A/1}).
 
 
 crud_test_() ->
@@ -27,24 +27,30 @@ crud_test_() ->
             setup,
             fun() -> test_util:start_couch([fabric]) end,
             fun test_util:stop_couch/1,
-            [
+            with([
                 ?TDEF(create_db),
                 ?TDEF(open_db),
                 ?TDEF(delete_db),
                 ?TDEF(list_dbs)
-            ]
+            ])
         }
     }.
 
 
-create_db() ->
+with(Tests) ->
+    fun(ArgsTuple) ->
+        [{Name, ?_test(Fun(ArgsTuple))} || {Name, Fun} <- Tests]
+    end.
+
+
+create_db(_) ->
     DbName = ?tempdb(),
     ?assertMatch({ok, _}, fabric2_db:create(DbName, [])),
     ?assertEqual(true, ets:member(fabric2_server, DbName)),
     ?assertEqual({error, file_exists}, fabric2_db:create(DbName, [])).
 
 
-open_db() ->
+open_db(_) ->
     DbName = ?tempdb(),
     ?assertError(database_does_not_exist, fabric2_db:open(DbName, [])),
 
@@ -59,7 +65,7 @@ open_db() ->
     ?assertMatch({ok, _}, fabric2_db:open(DbName, [])).
 
 
-delete_db() ->
+delete_db(_) ->
     DbName = ?tempdb(),
     ?assertError(database_does_not_exist, fabric2_db:delete(DbName, [])),
 
@@ -72,7 +78,7 @@ delete_db() ->
     ?assertError(database_does_not_exist, fabric2_db:open(DbName, [])).
 
 
-list_dbs() ->
+list_dbs(_) ->
     DbName = ?tempdb(),
     AllDbs1 = fabric2_db:list_dbs(),
 
diff --git a/src/fabric/test/fabric2_db_misc_tests.erl b/src/fabric/test/fabric2_db_misc_tests.erl
index 913b6aa..e4e6f34 100644
--- a/src/fabric/test/fabric2_db_misc_tests.erl
+++ b/src/fabric/test/fabric2_db_misc_tests.erl
@@ -29,16 +29,16 @@ misc_test_() ->
             setup,
             fun setup/0,
             fun cleanup/1,
-            {with, [
-                fun empty_db_info/1,
-                fun accessors/1,
-                fun set_revs_limit/1,
-                fun set_security/1,
-                fun is_system_db/1,
-                fun ensure_full_commit/1,
-                fun metadata_bump/1,
-                fun db_version_bump/1
-            ]}
+            with([
+                ?TDEF(empty_db_info),
+                ?TDEF(accessors),
+                ?TDEF(set_revs_limit),
+                ?TDEF(set_security),
+                ?TDEF(is_system_db),
+                ?TDEF(ensure_full_commit),
+                ?TDEF(metadata_bump),
+                ?TDEF(db_version_bump)
+            ])
         }
     }.
 
@@ -55,6 +55,12 @@ cleanup({_DbName, Db, Ctx}) ->
     test_util:stop_couch(Ctx).
 
 
+with(Tests) ->
+    fun(ArgsTuple) ->
+        [{Name, ?_test(Fun(ArgsTuple))} || {Name, Fun} <- Tests]
+    end.
+
+
 empty_db_info({DbName, Db, _}) ->
     {ok, Info} = fabric2_db:get_db_info(Db),
     ?assertEqual(DbName, fabric2_util:get_value(db_name, Info)),
diff --git a/src/fabric/test/fabric2_db_security_tests.erl b/src/fabric/test/fabric2_db_security_tests.erl
index 5015454..fbe10a3 100644
--- a/src/fabric/test/fabric2_db_security_tests.erl
+++ b/src/fabric/test/fabric2_db_security_tests.erl
@@ -18,6 +18,9 @@
 -include_lib("eunit/include/eunit.hrl").
 
 
+-define(TDEF(Name), {atom_to_list(Name), fun Name/1}).
+
+
 security_test_() ->
     {
         "Test database security operations",
@@ -25,22 +28,22 @@ security_test_() ->
             setup,
             fun setup/0,
             fun cleanup/1,
-            {with, [
-                fun check_is_admin/1,
-                fun check_is_not_admin/1,
-                fun check_is_admin_role/1,
-                fun check_is_not_admin_role/1,
-                fun check_is_member_name/1,
-                fun check_is_not_member_name/1,
-                fun check_is_member_role/1,
-                fun check_is_not_member_role/1,
-                fun check_admin_is_member/1,
-                fun check_is_member_of_public_db/1,
-                fun check_set_user_ctx/1,
-                fun check_forbidden/1,
-                fun check_fail_no_opts/1,
-                fun check_fail_name_null/1
-            ]}
+            with([
+                ?TDEF(check_is_admin),
+                ?TDEF(check_is_not_admin),
+                ?TDEF(check_is_admin_role),
+                ?TDEF(check_is_not_admin_role),
+                ?TDEF(check_is_member_name),
+                ?TDEF(check_is_not_member_name),
+                ?TDEF(check_is_member_role),
+                ?TDEF(check_is_not_member_role),
+                ?TDEF(check_admin_is_member),
+                ?TDEF(check_is_member_of_public_db),
+                ?TDEF(check_set_user_ctx),
+                ?TDEF(check_forbidden),
+                ?TDEF(check_fail_no_opts),
+                ?TDEF(check_fail_name_null)
+            ])
         }
     }.
 
@@ -71,6 +74,11 @@ cleanup({DbName, PubDbName, Ctx}) ->
     test_util:stop_couch(Ctx).
 
 
+with(Tests) ->
+    fun(ArgsTuple) ->
+        [{Name, ?_test(Fun(ArgsTuple))} || {Name, Fun} <- Tests]
+    end.
+
 
 check_is_admin({DbName, _, _}) ->
     UserCtx = #user_ctx{name = <<"admin_name1">>},
diff --git a/src/fabric/test/fabric2_dir_prefix_tests.erl b/src/fabric/test/fabric2_dir_prefix_tests.erl
index e4e78a3..e76340a 100644
--- a/src/fabric/test/fabric2_dir_prefix_tests.erl
+++ b/src/fabric/test/fabric2_dir_prefix_tests.erl
@@ -17,34 +17,37 @@
 -include_lib("eunit/include/eunit.hrl").
 
 
--define(TDEF(A), {atom_to_list(A), fun A/0}).
+-define(TDEF(A), {atom_to_list(A), fun A/1}).
 
 
 dir_prefix_test_() ->
     {
         "Test couchdb fdb directory prefix",
-        foreach,
+        setup,
         fun() ->
             % erlfdb, rexi and mem3 are all dependent apps for fabric. We make
             % sure to start them so when fabric is started during the test it
             % already has its dependencies
-            test_util:start_couch([erlfdb, rexi, mem3, ctrace])
+            test_util:start_couch([erlfdb, rexi, mem3, ctrace, fabric])
         end,
         fun(Ctx) ->
             config:delete("fabric", "fdb_directory"),
-            ok = application:stop(fabric),
             test_util:stop_couch(Ctx)
         end,
-        [
+        with([
             ?TDEF(default_prefix),
             ?TDEF(custom_prefix)
-        ]
+        ])
     }.
 
 
-default_prefix() ->
-    ok = application:start(fabric),
+with(Tests) ->
+    fun(ArgsTuple) ->
+        [{Name, ?_test(Fun(ArgsTuple))} || {Name, Fun} <- Tests]
+    end.
+
 
+default_prefix(_) ->
     ?assertEqual([<<"couchdb">>], fabric2_server:fdb_directory()),
 
     % Try again to test pdict caching code
@@ -55,8 +58,10 @@ default_prefix() ->
     ?assertMatch({ok, _}, fabric2_db:create(DbName, [])).
 
 
-custom_prefix() ->
-    ok = config:set("fabric", "fdb_directory", "couchdb_foo"),
+custom_prefix(_) ->
+    erase(fdb_directory),
+    ok = config:set("fabric", "fdb_directory", "couchdb_foo", false),
+    ok = application:stop(fabric),
     ok = application:start(fabric),
 
     ?assertEqual([<<"couchdb_foo">>], fabric2_server:fdb_directory()),
diff --git a/src/fabric/test/fabric2_doc_count_tests.erl b/src/fabric/test/fabric2_doc_count_tests.erl
index 743ae76..be652fc 100644
--- a/src/fabric/test/fabric2_doc_count_tests.erl
+++ b/src/fabric/test/fabric2_doc_count_tests.erl
@@ -18,6 +18,7 @@
 -include_lib("eunit/include/eunit.hrl").
 
 
+-define(TDEF(Name), {atom_to_list(Name), fun Name/1}).
 -define(DOC_COUNT, 10).
 
 
@@ -28,12 +29,12 @@ doc_count_test_() ->
             setup,
             fun setup/0,
             fun cleanup/1,
-            {with, [
-                fun normal_docs/1,
-                fun replicated_docs/1,
-                fun design_docs/1,
-                fun local_docs/1
-            ]}
+            with([
+                ?TDEF(normal_docs),
+                ?TDEF(replicated_docs),
+                ?TDEF(design_docs),
+                ?TDEF(local_docs)
+            ])
         }
     }.
 
@@ -49,6 +50,12 @@ cleanup({Db, Ctx}) ->
     test_util:stop_couch(Ctx).
 
 
+with(Tests) ->
+    fun(ArgsTuple) ->
+        [{Name, ?_test(Fun(ArgsTuple))} || {Name, Fun} <- Tests]
+    end.
+
+
 normal_docs({Db, _}) ->
     {DocCount, DelDocCount, DDocCount, LDocCount} = get_doc_counts(Db),
 
diff --git a/src/fabric/test/fabric2_doc_crud_tests.erl b/src/fabric/test/fabric2_doc_crud_tests.erl
index a9085be..f156a83 100644
--- a/src/fabric/test/fabric2_doc_crud_tests.erl
+++ b/src/fabric/test/fabric2_doc_crud_tests.erl
@@ -19,6 +19,9 @@
 -include("fabric2.hrl").
 
 
+-define(TDEF(Name), {atom_to_list(Name), fun Name/1}).
+
+
 doc_crud_test_() ->
     {
         "Test document CRUD operations",
@@ -26,48 +29,48 @@ doc_crud_test_() ->
             setup,
             fun setup/0,
             fun cleanup/1,
-            {with, [
-                fun open_missing_doc/1,
-                fun create_new_doc/1,
-                fun create_ddoc_basic/1,
-                fun create_ddoc_requires_admin/1,
-                fun create_ddoc_requires_validation/1,
-                fun create_ddoc_requires_compilation/1,
-                fun can_create_a_partitioned_ddoc/1,
-                fun update_doc_basic/1,
-                fun update_ddoc_basic/1,
-                fun update_doc_replicated/1,
-                fun update_doc_replicated_add_conflict/1,
-                fun update_doc_replicated_changes_winner/1,
-                fun update_doc_replicated_extension/1,
-                fun update_doc_replicate_existing_rev/1,
-                fun update_winning_conflict_branch/1,
-                fun update_non_winning_conflict_branch/1,
-                fun delete_doc_basic/1,
-                fun delete_changes_winner/1,
-                fun recreate_doc_basic/1,
-                fun conflict_on_create_new_with_rev/1,
-                fun conflict_on_update_with_no_rev/1,
-                fun conflict_on_create_as_deleted/1,
-                fun conflict_on_recreate_as_deleted/1,
-                fun conflict_on_extend_deleted/1,
-                fun open_doc_revs_basic/1,
-                fun open_doc_revs_all/1,
-                fun open_doc_revs_latest/1,
-                fun get_missing_revs_basic/1,
-                fun get_missing_revs_on_missing_doc/1,
-                fun open_missing_local_doc/1,
-                fun create_local_doc_basic/1,
-                fun update_local_doc_basic/1,
-                fun delete_local_doc_basic/1,
-                fun recreate_local_doc/1,
-                fun create_local_doc_bad_rev/1,
-                fun create_local_doc_random_rev/1,
-                fun create_a_large_local_doc/1,
-                fun create_2_large_local_docs/1,
-                fun local_doc_with_previous_encoding/1,
-                fun before_doc_update_skips_local_docs/1
-            ]}
+            with([
+                ?TDEF(open_missing_doc),
+                ?TDEF(create_new_doc),
+                ?TDEF(create_ddoc_basic),
+                ?TDEF(create_ddoc_requires_admin),
+                ?TDEF(create_ddoc_requires_validation),
+                ?TDEF(create_ddoc_requires_compilation),
+                ?TDEF(can_create_a_partitioned_ddoc),
+                ?TDEF(update_doc_basic),
+                ?TDEF(update_ddoc_basic),
+                ?TDEF(update_doc_replicated),
+                ?TDEF(update_doc_replicated_add_conflict),
+                ?TDEF(update_doc_replicated_changes_winner),
+                ?TDEF(update_doc_replicated_extension),
+                ?TDEF(update_doc_replicate_existing_rev),
+                ?TDEF(update_winning_conflict_branch),
+                ?TDEF(update_non_winning_conflict_branch),
+                ?TDEF(delete_doc_basic),
+                ?TDEF(delete_changes_winner),
+                ?TDEF(recreate_doc_basic),
+                ?TDEF(conflict_on_create_new_with_rev),
+                ?TDEF(conflict_on_update_with_no_rev),
+                ?TDEF(conflict_on_create_as_deleted),
+                ?TDEF(conflict_on_recreate_as_deleted),
+                ?TDEF(conflict_on_extend_deleted),
+                ?TDEF(open_doc_revs_basic),
+                ?TDEF(open_doc_revs_all),
+                ?TDEF(open_doc_revs_latest),
+                ?TDEF(get_missing_revs_basic),
+                ?TDEF(get_missing_revs_on_missing_doc),
+                ?TDEF(open_missing_local_doc),
+                ?TDEF(create_local_doc_basic),
+                ?TDEF(update_local_doc_basic),
+                ?TDEF(delete_local_doc_basic),
+                ?TDEF(recreate_local_doc),
+                ?TDEF(create_local_doc_bad_rev),
+                ?TDEF(create_local_doc_random_rev),
+                ?TDEF(create_a_large_local_doc),
+                ?TDEF(create_2_large_local_docs),
+                ?TDEF(local_doc_with_previous_encoding),
+                ?TDEF(before_doc_update_skips_local_docs)
+            ])
         }
     }.
 
@@ -83,6 +86,12 @@ cleanup({Db, Ctx}) ->
     test_util:stop_couch(Ctx).
 
 
+with(Tests) ->
+    fun(ArgsTuple) ->
+        [{Name, ?_test(Fun(ArgsTuple))} || {Name, Fun} <- Tests]
+    end.
+
+
 open_missing_doc({Db, _}) ->
     ?assertEqual({not_found, missing}, fabric2_db:open_doc(Db, <<"foo">>)).
 
diff --git a/src/fabric/test/fabric2_fdb_tx_retry_tests.erl b/src/fabric/test/fabric2_fdb_tx_retry_tests.erl
index c924ce5..d6599e7 100644
--- a/src/fabric/test/fabric2_fdb_tx_retry_tests.erl
+++ b/src/fabric/test/fabric2_fdb_tx_retry_tests.erl
@@ -16,10 +16,26 @@
 -include_lib("eunit/include/eunit.hrl").
 
 
--define(TDEF(A), {atom_to_list(A), fun A/0}).
+-define(TDEF(A), {atom_to_list(A), fun A/1}).
 
 
-meck_setup() ->
+retry_test_() ->
+    {
+        setup,
+        fun setup/0,
+        fun cleanup/1,
+        with([
+            ?TDEF(read_only_no_retry),
+            ?TDEF(read_only_commit_unknown_result),
+            ?TDEF(run_on_first_try),
+            ?TDEF(retry_when_commit_conflict),
+            ?TDEF(retry_when_txid_not_found),
+            ?TDEF(no_retry_when_txid_found)
+        ])
+    }.
+
+
+setup() ->
     meck:new(erlfdb),
     meck:new(fabric2_txids),
     EnvSt = case application:get_env(fabric, db) of
@@ -30,7 +46,7 @@ meck_setup() ->
     EnvSt.
 
 
-meck_cleanup(EnvSt) ->
+cleanup(EnvSt) ->
     case EnvSt of
         {ok, Db} -> application:set_env(fabric, db, Db);
         undefined -> application:unset_env(fabric, db)
@@ -38,23 +54,13 @@ meck_cleanup(EnvSt) ->
     meck:unload().
 
 
-retry_test_() ->
-    {
-        foreach,
-        fun meck_setup/0,
-        fun meck_cleanup/1,
-        [
-            ?TDEF(read_only_no_retry),
-            ?TDEF(read_only_commit_unknown_result),
-            ?TDEF(run_on_first_try),
-            ?TDEF(retry_when_commit_conflict),
-            ?TDEF(retry_when_txid_not_found),
-            ?TDEF(no_retry_when_txid_found)
-        ]
-    }.
+with(Tests) ->
+    fun(ArgsTuple) ->
+        [{Name, ?_test(Fun(ArgsTuple))} || {Name, Fun} <- Tests]
+    end.
 
 
-read_only_no_retry() ->
+read_only_no_retry(_) ->
     meck:expect(erlfdb, transactional, fun(_Db, UserFun) ->
         UserFun(not_a_real_transaction)
     end),
@@ -72,7 +78,7 @@ read_only_no_retry() ->
     ?assert(meck:validate([erlfdb, fabric2_txids])).
 
 
-read_only_commit_unknown_result() ->
+read_only_commit_unknown_result(_) ->
     % Not 100% certain that this would ever actually
     % happen in the wild but might as well test that
     % we don't blow up if it does.
@@ -93,7 +99,7 @@ read_only_commit_unknown_result() ->
     ?assert(meck:validate([erlfdb, fabric2_txids])).
 
 
-run_on_first_try() ->
+run_on_first_try(_) ->
     meck:expect(erlfdb, transactional, fun(_Db, UserFun) ->
         UserFun(not_a_real_transaction)
     end),
@@ -113,7 +119,7 @@ run_on_first_try() ->
     ?assert(meck:validate([erlfdb, fabric2_txids])).
 
 
-retry_when_commit_conflict() ->
+retry_when_commit_conflict(_) ->
     meck:expect(erlfdb, transactional, fun(_Db, UserFun) ->
         UserFun(not_a_real_transaction)
     end),
@@ -133,7 +139,7 @@ retry_when_commit_conflict() ->
     ?assert(meck:validate([erlfdb, fabric2_txids])).
 
 
-retry_when_txid_not_found() ->
+retry_when_txid_not_found(_) ->
     meck:expect(erlfdb, transactional, fun(_Db, UserFun) ->
         UserFun(not_a_real_transaction)
     end),
@@ -157,7 +163,7 @@ retry_when_txid_not_found() ->
     ?assert(meck:validate([erlfdb, fabric2_txids])).
 
 
-no_retry_when_txid_found() ->
+no_retry_when_txid_found(_) ->
     meck:expect(erlfdb, transactional, fun(_Db, UserFun) ->
         UserFun(not_a_real_transaction)
     end),
diff --git a/src/fabric/test/fabric2_node_types_tests.erl b/src/fabric/test/fabric2_node_types_tests.erl
index ad400f9..acbae00 100644
--- a/src/fabric/test/fabric2_node_types_tests.erl
+++ b/src/fabric/test/fabric2_node_types_tests.erl
@@ -16,13 +16,13 @@
 -include_lib("eunit/include/eunit.hrl").
 
 
--define(TDEF(A), {atom_to_list(A), fun A/0}).
+-define(TDEF(A), {atom_to_list(A), fun A/1}).
 
 
 node_types_test_() ->
     {
         "Test node types",
-        foreach,
+        setup,
         fun() ->
             os:putenv("COUCHDB_NODE_TYPE_FOO", "false"),
             os:putenv("COUCHDB_NODE_TYPE_BAZ", "true"),
@@ -30,26 +30,29 @@ node_types_test_() ->
             % erlfdb, rexi and mem3 are all dependent apps for fabric. We make
             % sure to start them so when fabric is started during the test it
             % already has its dependencies
-            test_util:start_couch([erlfdb, rexi, mem3, ctrace])
+            test_util:start_couch([erlfdb, rexi, mem3, ctrace, fabric])
         end,
         fun(Ctx) ->
-            ok = application:stop(fabric),
             test_util:stop_couch(Ctx),
             application:unset_env(fabric, node_types),
             os:unsetenv("COUCHDB_NODE_TYPE_FOO"),
             os:unsetenv("COUCHDB_NODE_TYPE_BAZ"),
             os:unsetenv("COUCHDB_NODE_TYPE_ZIG")
         end,
-        [
+        with([
             ?TDEF(basics),
             ?TDEF(os_env_priority)
-        ]
+        ])
     }.
 
 
-basics() ->
-    ok = application:start(fabric),
+with(Tests) ->
+    fun(ArgsTuple) ->
+        [{Name, ?_test(Fun(ArgsTuple))} || {Name, Fun} <- Tests]
+    end.
 
+
+basics(_) ->
     % default is true for new types
     ?assert(fabric2_node_types:is_type(some_new_node_type)),
 
@@ -64,9 +67,7 @@ basics() ->
     ?assert(not fabric2_node_types:is_type(bam)).
 
 
-os_env_priority() ->
-    ok = application:start(fabric),
-
+os_env_priority(_) ->
     % os env takes precedence
     application:set_env(fabric, node_types, [{foo, true}, {baz, false}]),
     ?assert(not fabric2_node_types:is_type(foo)),
diff --git a/src/fabric/test/fabric2_rev_stemming.erl b/src/fabric/test/fabric2_rev_stemming.erl
index 99e086e..1425362 100644
--- a/src/fabric/test/fabric2_rev_stemming.erl
+++ b/src/fabric/test/fabric2_rev_stemming.erl
@@ -18,6 +18,9 @@
 -include_lib("eunit/include/eunit.hrl").
 
 
+-define(TDEF(Name), {atom_to_list(Name), fun Name/1}).
+
+
 doc_crud_test_() ->
     {
         "Test document CRUD operations with stemming",
@@ -25,16 +28,16 @@ doc_crud_test_() ->
             setup,
             fun setup/0,
             fun cleanup/1,
-            {with, [
-                fun update_doc/1,
-                fun update_doc_replicated_no_stemming/1,
-                fun update_doc_replicated_with_stemming/1,
-                fun update_doc_replicate_existing_rev/1,
-                fun update_winning_conflict_branch/1,
-                fun update_non_winning_conflict_branch/1,
-                fun delete_doc_basic/1,
-                fun recreate_doc_basic/1
-            ]}
+            with([
+                ?TDEF(update_doc),
+                ?TDEF(update_doc_replicated_no_stemming),
+                ?TDEF(update_doc_replicated_with_stemming),
+                ?TDEF(update_doc_replicate_existing_rev),
+                ?TDEF(update_winning_conflict_branch),
+                ?TDEF(update_non_winning_conflict_branch),
+                ?TDEF(delete_doc_basic),
+                ?TDEF(recreate_doc_basic)
+            ])
         }
     }.
 
@@ -50,6 +53,12 @@ cleanup({Db, Ctx}) ->
     test_util:stop_couch(Ctx).
 
 
+with(Tests) ->
+    fun(ArgsTuple) ->
+        [{Name, ?_test(Fun(ArgsTuple))} || {Name, Fun} <- Tests]
+    end.
+
+
 update_doc({Db, _}) ->
     ok = fabric2_db:set_revs_limit(Db, 2),
     Doc1 = #doc{id = fabric2_util:uuid()},
@@ -192,7 +201,7 @@ recreate_doc_basic({Db, _}) ->
         deleted = true,
         body = {[{<<"state">>, 2}]}
     },
-    {ok, {2, Rev2}} = fabric2_db:update_doc(Db, Doc2),
+    {ok, {2, _Rev2}} = fabric2_db:update_doc(Db, Doc2),
     Doc3 = Doc1#doc{
         revs = {0, []},
         deleted = false,
diff --git a/src/fabric/test/fabric2_trace_db_create_tests.erl b/src/fabric/test/fabric2_trace_db_create_tests.erl
index 09cc863..b27af1f 100644
--- a/src/fabric/test/fabric2_trace_db_create_tests.erl
+++ b/src/fabric/test/fabric2_trace_db_create_tests.erl
@@ -18,6 +18,9 @@
 -include_lib("eunit/include/eunit.hrl").
 
 
+-define(TDEF(Name), {atom_to_list(Name), fun Name/1}).
+
+
 trace_test_() ->
     {
         "Trace operation",
@@ -25,9 +28,9 @@ trace_test_() ->
             setup,
             fun setup/0,
             fun cleanup/1,
-            [
-                fun create_db/0
-            ]
+            with([
+                ?TDEF(create_db)
+            ])
         }
     }.
 
@@ -41,6 +44,12 @@ cleanup(Ctx) ->
     test_util:stop_couch(Ctx).
 
 
-create_db() ->
+with(Tests) ->
+    fun(ArgsTuple) ->
+        [{Name, ?_test(Fun(ArgsTuple))} || {Name, Fun} <- Tests]
+    end.
+
+
+create_db(_) ->
     put(erlfdb_trace, <<"create db">>),
     {ok, _Db} = fabric2_db:create(?tempdb(), [{user_ctx, ?ADMIN_USER}]).
diff --git a/src/fabric/test/fabric2_trace_db_delete_tests.erl b/src/fabric/test/fabric2_trace_db_delete_tests.erl
index ddbb2c8..1a9e607 100644
--- a/src/fabric/test/fabric2_trace_db_delete_tests.erl
+++ b/src/fabric/test/fabric2_trace_db_delete_tests.erl
@@ -18,6 +18,9 @@
 -include_lib("eunit/include/eunit.hrl").
 
 
+-define(TDEF(Name), {atom_to_list(Name), fun Name/1}).
+
+
 trace_test_() ->
     {
         "Trace operation",
@@ -25,9 +28,9 @@ trace_test_() ->
             setup,
             fun setup/0,
             fun cleanup/1,
-            {with, [
-                fun delete_db/1
-            ]}
+            with([
+                ?TDEF(delete_db)
+            ])
         }
     }.
 
@@ -43,6 +46,12 @@ cleanup({_Db, Ctx}) ->
     test_util:stop_couch(Ctx).
 
 
+with(Tests) ->
+    fun(ArgsTuple) ->
+        [{Name, ?_test(Fun(ArgsTuple))} || {Name, Fun} <- Tests]
+    end.
+
+
 delete_db({Db, _}) ->
     put(erlfdb_trace, <<"delete db">>),
     fabric2_server:remove(fabric2_db:name(Db)),
diff --git a/src/fabric/test/fabric2_trace_db_open_tests.erl b/src/fabric/test/fabric2_trace_db_open_tests.erl
index 71e3301..0c3ef17 100644
--- a/src/fabric/test/fabric2_trace_db_open_tests.erl
+++ b/src/fabric/test/fabric2_trace_db_open_tests.erl
@@ -18,6 +18,9 @@
 -include_lib("eunit/include/eunit.hrl").
 
 
+-define(TDEF(Name), {atom_to_list(Name), fun Name/1}).
+
+
 trace_test_() ->
     {
         "Trace operation",
@@ -25,9 +28,9 @@ trace_test_() ->
             setup,
             fun setup/0,
             fun cleanup/1,
-            {with, [
-                fun open_db/1
-            ]}
+            with([
+                ?TDEF(open_db)
+            ])
         }
     }.
 
@@ -44,6 +47,12 @@ cleanup({Db, Ctx}) ->
     test_util:stop_couch(Ctx).
 
 
+with(Tests) ->
+    fun(ArgsTuple) ->
+        [{Name, ?_test(Fun(ArgsTuple))} || {Name, Fun} <- Tests]
+    end.
+
+
 open_db({Db, _}) ->
     put(erlfdb_trace, <<"open db">>),
     fabric2_server:remove(fabric2_db:name(Db)),
diff --git a/src/fabric/test/fabric2_trace_doc_create_tests.erl b/src/fabric/test/fabric2_trace_doc_create_tests.erl
index 1e0b47c..7287fca 100644
--- a/src/fabric/test/fabric2_trace_doc_create_tests.erl
+++ b/src/fabric/test/fabric2_trace_doc_create_tests.erl
@@ -18,18 +18,20 @@
 -include_lib("eunit/include/eunit.hrl").
 
 
-doc_crud_test_() ->
+-define(TDEF(Name), {atom_to_list(Name), fun Name/1}).
+
+trace_doc_create_test_() ->
     {
         "Test document CRUD operations",
         {
             setup,
             fun setup/0,
             fun cleanup/1,
-            {with, [
-                fun create_new_doc/1,
-                fun create_two_docs/1,
-                fun create_50_docs/1
-            ]}
+            with([
+                ?TDEF(create_new_doc),
+                ?TDEF(create_two_docs),
+                ?TDEF(create_50_docs)
+            ])
         }
     }.
 
@@ -45,6 +47,12 @@ cleanup({Db, Ctx}) ->
     test_util:stop_couch(Ctx).
 
 
+with(Tests) ->
+    fun(ArgsTuple) ->
+        [{Name, ?_test(Fun(ArgsTuple))} || {Name, Fun} <- Tests]
+    end.
+
+
 create_new_doc({Db, _}) ->
     put(erlfdb_trace, <<"one doc">>),
     Doc = #doc{


Mime
View raw message