You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2020/02/15 18:44:07 UTC

[couchdb] 02/05: Test coverage: list_dbs and list_dbs_info

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

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

commit 8a792ad78d5744a93dcd9ca5908d9e0e889e5242
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Fri Feb 14 11:17:15 2020 -0600

    Test coverage: list_dbs and list_dbs_info
---
 src/fabric/test/fabric2_db_crud_tests.erl | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/fabric/test/fabric2_db_crud_tests.erl b/src/fabric/test/fabric2_db_crud_tests.erl
index 8052551..943b55f 100644
--- a/src/fabric/test/fabric2_db_crud_tests.erl
+++ b/src/fabric/test/fabric2_db_crud_tests.erl
@@ -30,7 +30,10 @@ crud_test_() ->
                 ?TDEF(open_db),
                 ?TDEF(delete_db),
                 ?TDEF(list_dbs),
-                ?TDEF(list_dbs_info)
+                ?TDEF(list_dbs_user_fun),
+                ?TDEF(list_dbs_user_fun_partial),
+                ?TDEF(list_dbs_info),
+                ?TDEF(list_dbs_info_partial)
             ])
         }
     }.
@@ -87,6 +90,26 @@ list_dbs(_) ->
     ?assert(not lists:member(DbName, AllDbs3)).
 
 
+list_dbs_user_fun(_) ->
+    ?assertMatch({ok, _}, fabric2_db:create(?tempdb(), [])),
+
+    UserFun = fun(Row, Acc) -> {ok, [Row | Acc]} end,
+    {ok, UserAcc} = fabric2_db:list_dbs(UserFun, [], []),
+
+    Base = lists:foldl(fun(DbName, Acc) ->
+        [{row, [{id, DbName}]} | Acc]
+    end, [{meta, []}], fabric2_db:list_dbs()),
+    Expect = lists:reverse(Base, [complete]),
+
+    ?assertEqual(Expect, lists:reverse(UserAcc)).
+
+
+list_dbs_user_fun_partial(_) ->
+    UserFun = fun(Row, Acc) -> {stop, [Row | Acc]} end,
+    {ok, UserAcc} = fabric2_db:list_dbs(UserFun, [], []),
+    ?assertEqual([{meta, []}], UserAcc).
+
+
 list_dbs_info(_) ->
     DbName = ?tempdb(),
     {ok, AllDbInfos1} = fabric2_db:list_dbs_info(),
@@ -103,6 +126,12 @@ list_dbs_info(_) ->
     ?assert(not is_db_info_member(DbName, AllDbInfos3)).
 
 
+list_dbs_info_partial(_) ->
+    UserFun = fun(Row, Acc) -> {stop, [Row | Acc]} end,
+    {ok, UserAcc} = fabric2_db:list_dbs_info(UserFun, [], []),
+    ?assertEqual([{meta, []}], UserAcc).
+
+
 is_db_info_member(_, []) ->
     false;