You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2023/04/17 18:41:26 UTC

[couchdb] 02/03: Fix couch_etag_tests: local_with_body_test

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

jaydoane pushed a commit to branch otp-26-compat
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 015c1824b519cf06f9db2f13053ba8cc3b7f0f1c
Author: Jay Doane <ja...@apache.org>
AuthorDate: Thu Apr 13 15:36:37 2023 -0700

    Fix couch_etag_tests: local_with_body_test
    
    - Force Latin-1 encoding for backward compatibility.
    - Place expected value first in assert statements.
---
 src/couch/src/couch_httpd.erl             | 2 +-
 src/couch/test/eunit/couch_etag_tests.erl | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/couch/src/couch_httpd.erl b/src/couch/src/couch_httpd.erl
index 76f8279f6..f3187e3f0 100644
--- a/src/couch/src/couch_httpd.erl
+++ b/src/couch/src/couch_httpd.erl
@@ -745,7 +745,7 @@ rev_etag({Start, DiskRev}) ->
     <<$", Rev/binary, $">>.
 
 make_etag(Term) ->
-    <<SigInt:128/integer>> = couch_hash:md5_hash(term_to_binary(Term)),
+    <<SigInt:128/integer>> = couch_hash:md5_hash(term_to_binary(Term, [{minor_version,1}])),
     iolist_to_binary([$", io_lib:format("~.36B", [SigInt]), $"]).
 
 etag_match(Req, CurrentEtag) when is_binary(CurrentEtag) ->
diff --git a/src/couch/test/eunit/couch_etag_tests.erl b/src/couch/test/eunit/couch_etag_tests.erl
index 72db6008a..4c4fba2c7 100644
--- a/src/couch/test/eunit/couch_etag_tests.erl
+++ b/src/couch/test/eunit/couch_etag_tests.erl
@@ -16,16 +16,16 @@
 
 local_with_empty_body_test() ->
     Etag = couch_httpd:doc_etag(<<"_local/local-and-empty">>, {[]}, {0, <<"1">>}),
-    ?assertEqual(Etag, <<"\"5ZVXQYO7VLEOU0TL9VXDNP5PV\"">>).
+    ?assertEqual( <<"\"5ZVXQYO7VLEOU0TL9VXDNP5PV\"">>, Etag).
 
 local_with_body_test() ->
     DocBody = {[{<<"hello">>, <<"world">>}, {<<"relax">>, true}]},
     Etag = couch_httpd:doc_etag(<<"_local/local-with-body">>, DocBody, {0, <<"1">>}),
-    ?assertEqual(Etag, <<"\"CEFXP6WH8OKYIWO1GLGBHKCCA\"">>).
+    ?assertEqual(<<"\"CEFXP6WH8OKYIWO1GLGBHKCCA\"">>, Etag).
 
 normal_doc_uses_rev_test() ->
     DocBody = {[{<<"hello">>, <<"world">>}, {<<"relax">>, true}]},
     Etag = couch_httpd:doc_etag(
         <<"nomal-doc">>, DocBody, {1, <<"efda11e34e88ebe31a2f83e84a0435b6">>}
     ),
-    ?assertEqual(Etag, <<"\"1-efda11e34e88ebe31a2f83e84a0435b6\"">>).
+    ?assertEqual(<<"\"1-efda11e34e88ebe31a2f83e84a0435b6\"">>, Etag).