rnewson commented on code in PR #6063:
URL: https://github.com/apache/couchdb/pull/6063#discussion_r3613745973


##########
src/chttpd/src/chttpd.erl:
##########
@@ -1694,4 +1718,28 @@ handle_req_after_auth_test() ->
     ok = meck:unload(chttpd_handlers),
     ok = meck:unload(chttpd_auth).
 
+custom_peer_test() ->
+    Headers = mochiweb_headers:make([
+        {"HOST", "127.0.0.1:15984"}, {"X-Couch-Client-IP", "right_peer"}
+    ]),
+    MochiReq = mochiweb_request:new(
+        socket,
+        [],
+        'PUT',
+        "/newdb",
+        version,
+        Headers
+    ),
+    Req = #httpd{
+        mochi_req = MochiReq,
+        begin_ts = {1458, 588713, 124003},
+        original_method = 'GET',
+        peer = "wrong_peer",
+        nonce = "nonce"
+    },
+    ok = meck:new(config, [passthrough]),
+    ok = meck:expect(config, get, fun("chttpd", "peer_header") -> 
"x-couch-client-ip" end),
+    ?assertEqual("right_peer", peer(Req)),
+    ok = meck:unload(config).

Review Comment:
   yeah, I followed the module shape but the existing tests are not well 
structured. still, if tests all pass then it all works out... :)



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to