Repository: couchdb-couch Updated Branches: refs/heads/master 1df597fc2 -> 7ee0b8161
Fix the case when DbName contains path to db file In the case when DbName contains the file name we need to remove .couch extension in order to match ?DBNAME_REGEX. COUCHDB-3080 Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/93c2c62f Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/93c2c62f Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/93c2c62f Branch: refs/heads/master Commit: 93c2c62f3e8e23d4e6fe1c48619eb767f229801b Parents: 6b1796f Author: ILYA Khlopotov <iil...@ca.ibm.com> Authored: Mon Jul 25 15:23:30 2016 -0700 Committer: ILYA Khlopotov <iil...@ca.ibm.com> Committed: Tue Aug 9 15:27:48 2016 -0700 ---------------------------------------------------------------------- src/couch_db.erl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/93c2c62f/src/couch_db.erl ---------------------------------------------------------------------- diff --git a/src/couch_db.erl b/src/couch_db.erl index 229bf4f..26c6ae7 100644 --- a/src/couch_db.erl +++ b/src/couch_db.erl @@ -1544,7 +1544,8 @@ validate_dbname(DbName) when is_binary(DbName) -> DbName, Normalized, fun validate_dbname_int/2). validate_dbname_int(DbName, Normalized) when is_binary(DbName) -> - case re:run(DbName, ?DBNAME_REGEX, [{capture,none}, dollar_endonly]) of + DbNoExt = maybe_remove_extension(DbName), + case re:run(DbNoExt, ?DBNAME_REGEX, [{capture,none}, dollar_endonly]) of match -> ok; nomatch -> @@ -1563,23 +1564,23 @@ is_systemdb(DbName) when is_binary(DbName) -> -include_lib("eunit/include/eunit.hrl"). setup() -> - ok = meck:new(couch_db_plugin, [passthrough]), - ok = meck:expect(couch_db_plugin, validate_dbname, fun(_, _) -> false end), + ok = meck:new(couch_epi, [passthrough]), + ok = meck:expect(couch_epi, decide, fun(_, _, _, _, _) -> no_decision end), ok. teardown(_) -> - (catch meck:unload(couch_db_plugin)). + (catch meck:unload(couch_epi)). validate_dbname_success_test_() -> Cases = - generate_cases_with_shards("long/co$mplex-/path+/_something") + generate_cases_with_shards("long/co$mplex-/path+/something") ++ generate_cases_with_shards("something") ++ lists:append( [generate_cases_with_shards(?b2l(SystemDb)) || SystemDb <- ?SYSTEM_DATABASES]), { foreach, fun setup/0, fun teardown/1, - [{test_name(A), fun() -> should_pass_validate_dbname(A) end} || {_, A} <- Cases] + [should_pass_validate_dbname(A) || {_, A} <- Cases] }. validate_dbname_fail_test_() -> @@ -1589,7 +1590,7 @@ validate_dbname_fail_test_() -> ++ generate_cases_with_shards("long/co$mplex-/path+/some.thing"), { foreach, fun setup/0, fun teardown/1, - [{test_name(A), fun() -> should_fail_validate_dbname(A) end} || {_, A} <- Cases] + [should_fail_validate_dbname(A) || {_, A} <- Cases] }. normalize_dbname_test_() ->