diff options
author | iilyak <iilyak@users.noreply.github.com> | 2019-07-29 07:44:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-29 07:44:08 -0700 |
commit | f37e1e73205e98d6a74a714a23c4a59f7cf2bb0b (patch) | |
tree | cdc6c540ed1b43ec6363bade88ef853378b52ec1 /src/ddoc_cache/test/eunit/ddoc_cache_disabled_test.erl | |
parent | 29d484e45054c4b40f6b3a223298c8a31914f90d (diff) | |
parent | 25ad74a6cdc03732265d5175218e96a004dd4c40 (diff) | |
download | couchdb-f37e1e73205e98d6a74a714a23c4a59f7cf2bb0b.tar.gz |
Merge pull request #2039 from cloudant/exunit-simplified
Exunit simplified
Diffstat (limited to 'src/ddoc_cache/test/eunit/ddoc_cache_disabled_test.erl')
-rw-r--r-- | src/ddoc_cache/test/eunit/ddoc_cache_disabled_test.erl | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/ddoc_cache/test/eunit/ddoc_cache_disabled_test.erl b/src/ddoc_cache/test/eunit/ddoc_cache_disabled_test.erl new file mode 100644 index 000000000..d46bdde32 --- /dev/null +++ b/src/ddoc_cache/test/eunit/ddoc_cache_disabled_test.erl @@ -0,0 +1,62 @@ +% Licensed under the Apache License, Version 2.0 (the "License"); you may not +% use this file except in compliance with the License. You may obtain a copy of +% the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +% License for the specific language governing permissions and limitations under +% the License. + +-module(ddoc_cache_disabled_test). + + +-include_lib("couch/include/couch_db.hrl"). +-include_lib("eunit/include/eunit.hrl"). +-include("ddoc_cache_test.hrl"). + + +start_couch() -> + Ctx = ddoc_cache_tutil:start_couch(), + config:set("ddoc_cache", "max_size", "0", false), + Ctx. + + +check_disabled_test_() -> + { + setup, + fun start_couch/0, + fun ddoc_cache_tutil:stop_couch/1, + ddoc_cache_tutil:with([ + {"resp_ok", fun resp_ok/1}, + {"resp_not_found", fun resp_not_found/1}, + {"check_effectively_disabled", fun check_effectively_disabled/1} + ]) + }. + + +resp_ok({DbName, _}) -> + ddoc_cache_tutil:clear(), + Resp = ddoc_cache:open_doc(DbName, ?FOOBAR), + ?assertMatch({ok, #doc{id = ?FOOBAR}}, Resp), + ?assertEqual(0, ets:info(?CACHE, size)), + ?assertEqual(0, ets:info(?LRU, size)). + + +resp_not_found({DbName, _}) -> + ddoc_cache_tutil:clear(), + Resp = ddoc_cache:open_doc(DbName, <<"_design/not_found">>), + ?assertEqual({not_found, missing}, Resp), + ?assertEqual(0, ets:info(?CACHE, size)), + ?assertEqual(0, ets:info(?LRU, size)). + + +check_effectively_disabled({DbName, _}) -> + config:set("ddoc_cache", "max_size", "1", false), + ddoc_cache_tutil:clear(), + Resp = ddoc_cache:open_doc(DbName, ?FOOBAR), + ?assertMatch({ok, #doc{id = ?FOOBAR}}, Resp), + ?assertEqual(0, ets:info(?CACHE, size)), + ?assertEqual(0, ets:info(?LRU, size)). |