You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2019/12/25 17:45:19 UTC

[couchdb] 16/41: Speedup eunit: chttpd_xframe_test

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch speedup-test-suite
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit d03cac7360691c8951f8791a23586c35d0eb8c20
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed Dec 25 11:31:03 2019 -0600

    Speedup eunit: chttpd_xframe_test
---
 src/chttpd/test/eunit/chttpd_xframe_test.erl | 29 ++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/chttpd/test/eunit/chttpd_xframe_test.erl b/src/chttpd/test/eunit/chttpd_xframe_test.erl
index 1272c19..f3e6165 100644
--- a/src/chttpd/test/eunit/chttpd_xframe_test.erl
+++ b/src/chttpd/test/eunit/chttpd_xframe_test.erl
@@ -4,13 +4,19 @@
 -include_lib("couch/include/couch_db.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
-setup() ->
+setup_all() ->
     ok = meck:new(config),
     ok = meck:expect(config, get, fun(_, _, _) -> "X-Forwarded-Host" end),
     ok.
 
+teardown_all(_) ->
+    meck:unload().
+
+setup() ->
+    meck:reset([config]).
+
 teardown(_) ->
-    meck:unload(config).
+    ok.
 
 mock_request() ->
     Headers = mochiweb_headers:make([{"Host", "examples.com"}]),
@@ -62,12 +68,19 @@ xframe_host_test_() ->
     {
         "xframe host tests",
         {
-            foreach, fun setup/0, fun teardown/1,
-            [
-                fun allow_with_wildcard_host/1,
-                fun allow_with_specific_host/1,
-                fun deny_with_different_host/1
-            ]
+            setup,
+            fun setup_all/0,
+            fun teardown_all/1,
+            {
+                foreach,
+                fun setup/0,
+                fun teardown/1,
+                [
+                    fun allow_with_wildcard_host/1,
+                    fun allow_with_specific_host/1,
+                    fun deny_with_different_host/1
+                ]
+            }
         }
     }.