Skip to content

Commit

Permalink
mango: plug hole in unit test coverage of view cursor functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pgj committed Sep 15, 2023
1 parent b22fda3 commit c8521cb
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/mango/src/mango_cursor_view.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]
}.

Expand Down Expand Up @@ -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},
Expand All @@ -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,
Expand Down

0 comments on commit c8521cb

Please sign in to comment.