You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2022/02/03 17:26:17 UTC

[GitHub] [couchdb] jiahuili430 commented on a change in pull request #3923: Execute chttpd_dbs_info_tests in clean database_dir

jiahuili430 commented on a change in pull request #3923:
URL: https://github.com/apache/couchdb/pull/3923#discussion_r798803670



##########
File path: src/chttpd/test/eunit/chttpd_dbs_info_test.erl
##########
@@ -14,358 +14,264 @@
 
 -include_lib("couch/include/couch_eunit.hrl").
 -include_lib("couch/include/couch_db.hrl").
+-include("chttpd_test.hrl").
 
 -define(USER, "chttpd_db_test_admin").
 -define(PASS, "pass").
 -define(AUTH, {basic_auth, {?USER, ?PASS}}).
 -define(CONTENT_JSON, {"Content-Type", "application/json"}).
 
+start() ->
+    Ctx = chttpd_test_util:start_couch(),
+    DbDir = config:get("couchdb", "database_dir"),
+    Suffix = ?b2l(couch_uuids:random()),
+    test_util:with_couch_server_restart(fun() ->
+        config:set("couchdb", "database_dir", DbDir ++ "/" ++ Suffix, false)
+    end),
+    mock([fabric_util, chttpd_util]),
+    Ctx.
+
+stop(Ctx) ->
+    config:delete("couchdb", "database_dir", false),
+    chttpd_test_util:stop_couch(Ctx).
+
 setup() ->
     Hashed = couch_passwords:hash_admin_password(?PASS),
     ok = config:set("admins", ?USER, ?b2l(Hashed), _Persist = false),
-    Addr = config:get("chttpd", "bind_address", "127.0.0.1"),
-    Port = mochiweb_socket_server:get(chttpd, port),
-    Url = lists:concat(["http://", Addr, ":", Port, "/"]),
-    Db1Url = lists:concat([Url, "db1"]),
-    create_db(Db1Url),
-    Db2Url = lists:concat([Url, "db2"]),
-    create_db(Db2Url),
-    mock(fabric_util),
-    mock(chttpd_util),
-    Url.
-
-teardown(Url) ->
+    Suffix = ?b2l(couch_uuids:random()),
+    Db1 = testdb("db1", Suffix),
+    Db2 = testdb("db2", Suffix),
+    create_db(base_url(Db1)),
+    create_db(base_url(Db2)),
+    {Suffix, Db1, Db2}.
+
+teardown({_, Db1, Db2}) ->
     meck:unload(),
-    Db1Url = lists:concat([Url, "db1"]),
-    Db2Url = lists:concat([Url, "db2"]),
-    delete_db(Db1Url),
-    delete_db(Db2Url),
+    config:delete("couchdb", "database_dir", false),

Review comment:
       Forgot to remove it, thanks for the review.




-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org