nickva commented on code in PR #4862:
URL: https://github.com/apache/couchdb/pull/4862#discussion_r1442050851
##########
src/chttpd/test/eunit/chttpd_changes_test.erl:
##########
@@ -1016,3 +1068,8 @@ seq(<<_/binary>> = Seq) ->
binary_to_integer(NumStr);
seq(null) ->
null.
+
+called_times(ReqFun) ->
+ meck:reset(couch_db),
+ ReqFun(),
+ meck:num_calls(couch_db, open_doc, 3).
Review Comment:
If we wanted to be a bit more precise about the number of calls to open_doc
just for our db and only with doc_infos:
```erlang
called_times(ReqFun, DbUrl) ->
meck:reset(couch_db),
ReqFun(),
open_doc_calls(DbUrl).
open_doc_calls(DbUrl) ->
#{path := "/" ++ DbName0} = uri_string:parse(DbUrl),
DbName = list_to_binary(DbName0),
FoldFun = fun([Db, IdOrDocInfo, _Opts], Acc) ->
case {mem3:dbname(couch_db:name(Db)), IdOrDocInfo} of
{DbName, #doc_info{}} -> Acc + 1;
{_, _}-> Acc
end
end,
lists:foldl(FoldFun, 0, meck_history(couch_db, open_doc, 3)).
meck_history(Mod, Fun, Arity) ->
[A || {_, {_, F, A}, _} <- meck:history(Mod), F =:= Fun, length(A) =:=
Arity].
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]