You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ch...@apache.org on 2014/08/28 19:35:00 UTC
[05/50] [abbrv] couch commit: updated refs/heads/1963-eunit-bigcouch
to 3ecd0a0
Port 070-couch-db.t etap test suite to eunit
Fix ERL_LIB environment variable setting. Add ?tempdb macros for
unique temporary database name generation.
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/3505768a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/3505768a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/3505768a
Branch: refs/heads/1963-eunit-bigcouch
Commit: 3505768ac16aaa7d78ab8f8c9dd2eb2d3727d01a
Parents: 4d00c4f
Author: Alexander Shorin <kx...@apache.org>
Authored: Mon May 19 05:36:06 2014 +0400
Committer: Russell Branca <ch...@apache.org>
Committed: Thu Aug 28 10:34:04 2014 -0700
----------------------------------------------------------------------
test/couchdb/couch_db_tests.erl | 90 ++++++++++++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/3505768a/test/couchdb/couch_db_tests.erl
----------------------------------------------------------------------
diff --git a/test/couchdb/couch_db_tests.erl b/test/couchdb/couch_db_tests.erl
new file mode 100644
index 0000000..2b781ed
--- /dev/null
+++ b/test/couchdb/couch_db_tests.erl
@@ -0,0 +1,90 @@
+% 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(couch_db_tests).
+
+-include("couch_eunit.hrl").
+
+
+setup() ->
+ {ok, _} = couch_server_sup:start_link(?CONFIG_CHAIN),
+ ok.
+
+teardown(_) ->
+ couch_server_sup:stop().
+
+
+create_delete_db_test_()->
+ {
+ "Database create/delete tests",
+ {
+ setup,
+ fun setup/0, fun teardown/1,
+ fun(_) ->
+ [should_create_db(),
+ should_delete_db(),
+ should_create_multiple_dbs(),
+ should_delete_multiple_dbs()]
+ end
+ }
+ }.
+
+
+should_create_db() ->
+ DbName = ?tempdb(),
+ {ok, Db} = couch_db:create(DbName, []),
+ ok = couch_db:close(Db),
+ {ok, AllDbs} = couch_server:all_databases(),
+ ?_assert(lists:member(DbName, AllDbs)).
+
+should_delete_db() ->
+ DbName = ?tempdb(),
+ couch_db:create(DbName, []),
+ couch_server:delete(DbName, []),
+ {ok, AllDbs} = couch_server:all_databases(),
+ ?_assertNot(lists:member(DbName, AllDbs)).
+
+should_create_multiple_dbs() ->
+ gen_server:call(couch_server, {set_max_dbs_open, 3}),
+
+ DbNames = [?tempdb() || _ <- lists:seq(1, 6)],
+ lists:foreach(fun(DbName) ->
+ {ok, Db} = couch_db:create(DbName, []),
+ ok = couch_db:close(Db)
+ end, DbNames),
+
+ {ok, AllDbs} = couch_server:all_databases(),
+ NumCreated = lists:foldl(fun(DbName, Acc) ->
+ ?assert(lists:member(DbName, AllDbs)),
+ Acc+1
+ end, 0, DbNames),
+
+ ?_assertEqual(NumCreated, 6).
+
+should_delete_multiple_dbs() ->
+ DbNames = [?tempdb() || _ <- lists:seq(1, 6)],
+ lists:foreach(fun(DbName) ->
+ {ok, Db} = couch_db:create(DbName, []),
+ ok = couch_db:close(Db)
+ end, DbNames),
+
+ lists:foreach(fun(DbName) ->
+ ok = couch_server:delete(DbName, [])
+ end, DbNames),
+
+ {ok, AllDbs} = couch_server:all_databases(),
+ NumDeleted = lists:foldl(fun(DbName, Acc) ->
+ ?assertNot(lists:member(DbName, AllDbs)),
+ Acc + 1
+ end, 0, DbNames),
+
+ ?_assertEqual(NumDeleted, 6).