You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2023/03/23 10:56:14 UTC
[couchdb] 01/01: eunit test to assert ddoc_updated clause doesn't throw
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch add_db_event_crash_test
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit fdf43f232d79e2c3f13f34431e65ac22ce66682e
Author: Robert Newson <rn...@apache.org>
AuthorDate: Thu Mar 23 10:54:43 2023 +0000
eunit test to assert ddoc_updated clause doesn't throw
We pass in a shard name that doesn't exist, causing couch_util:with_db to throw.
we assert that we get back {ok, St} and don't crash.
---
.../test/eunit/couch_index_ddoc_updated_tests.erl | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/couch_index/test/eunit/couch_index_ddoc_updated_tests.erl b/src/couch_index/test/eunit/couch_index_ddoc_updated_tests.erl
index cbdb71954..6536ece8e 100644
--- a/src/couch_index/test/eunit/couch_index_ddoc_updated_tests.erl
+++ b/src/couch_index/test/eunit/couch_index_ddoc_updated_tests.erl
@@ -126,6 +126,19 @@ check_all_indexers_exit_on_ddoc_change({_Ctx, DbName}) ->
ok
end).
+db_event_crash_test() ->
+ St =
+ {st, "", couch_index_server:server_name(1), couch_index_server:by_sig(1),
+ couch_index_server:by_pid(1), couch_index_server:by_db(1),
+ couch_index_server:openers(1)},
+ %% Assert that we get back what we sent in, and implicitly didn't crash instead.
+ ?assertEqual(
+ {ok, St},
+ couch_index_server:handle_db_event(
+ <<"shards/fake">>, {ddoc_updated, <<"fakeddoc">>}, St
+ )
+ ).
+
fake_index() ->
ok = meck:new([test_index], [non_strict]),
ok = meck:expect(test_index, init, fun(Db, DDoc) ->