You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by pg...@apache.org on 2023/09/15 14:20:21 UTC

[couchdb] branch main updated: mango: plug hole in unit test coverage of view cursor functions

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

pgj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/main by this push:
     new c8521cba9 mango: plug hole in unit test coverage of view cursor functions
c8521cba9 is described below

commit c8521cba9aa440374829689bddb258ea50bd9dd0
Author: Gabor Pali <ga...@ibm.com>
AuthorDate: Fri Sep 15 12:45:00 2023 +0200

    mango: plug hole in unit test coverage of view cursor functions
---
 src/mango/src/mango_cursor_view.erl | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/mango/src/mango_cursor_view.erl b/src/mango/src/mango_cursor_view.erl
index 1f6594e31..41006ce77 100644
--- a/src/mango/src/mango_cursor_view.erl
+++ b/src/mango/src/mango_cursor_view.erl
@@ -1003,7 +1003,8 @@ execute_test_() ->
             ?TDEF_FE(t_execute_ok_all_docs),
             ?TDEF_FE(t_execute_ok_all_docs_with_execution_stats),
             ?TDEF_FE(t_execute_ok_query_view),
-            ?TDEF_FE(t_execute_error)
+            ?TDEF_FE(t_execute_error_1),
+            ?TDEF_FE(t_execute_error_2)
         ]
     }.
 
@@ -1216,7 +1217,7 @@ t_execute_ok_all_docs_with_execution_stats(_) ->
     ?assertEqual({ok, updated_accumulator2}, execute(Cursor, fun foo:bar/2, accumulator)),
     ?assert(meck:called(fabric, all_docs, '_')).
 
-t_execute_error(_) ->
+t_execute_error_1(_) ->
     Cursor =
         #cursor{
             index = #idx{type = <<"json">>, ddoc = <<"_design/ghibli">>, name = index_name},
@@ -1233,6 +1234,23 @@ t_execute_error(_) ->
     meck:expect(fabric, query_view, Parameters, meck:val({error, reason})),
     ?assertEqual({error, reason}, execute(Cursor, undefined, accumulator)).
 
+t_execute_error_2(_) ->
+    Cursor =
+        #cursor{
+            index = #idx{type = <<"json">>, ddoc = <<"_design/ghibli">>, name = index_name},
+            db = db,
+            selector = {[]},
+            fields = all_fields,
+            ranges = [{'$gte', start_key, '$lte', end_key}],
+            opts = [{user_ctx, user_ctx}],
+            bookmark = nil
+        },
+    Parameters = [
+        db, '_', <<"ghibli">>, index_name, fun mango_cursor_view:handle_message/2, '_', '_'
+    ],
+    meck:expect(fabric, query_view, Parameters, meck:val({ok, {error, reason}})),
+    ?assertEqual({error, {error, reason}}, execute(Cursor, undefined, accumulator)).
+
 view_cb_test_() ->
     {
         foreach,