You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wo...@apache.org on 2018/11/08 00:37:54 UTC

[couchdb] branch master updated: #1705 Add UUID attribute to welcome message (#1708)

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

wohali pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/master by this push:
     new c157c96  #1705 Add UUID attribute to welcome message (#1708)
c157c96 is described below

commit c157c968b349112c5b3e69a3ded7aca7996e761d
Author: Ryan Gordon <ry...@gmail.com>
AuthorDate: Thu Nov 8 00:37:49 2018 +0000

    #1705 Add UUID attribute to welcome message (#1708)
---
 src/chttpd/src/chttpd_misc.erl          |  1 +
 src/chttpd/test/chttpd_welcome_test.erl | 20 +++++++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/chttpd/src/chttpd_misc.erl b/src/chttpd/src/chttpd_misc.erl
index 39ffa23..1a6b3cb 100644
--- a/src/chttpd/src/chttpd_misc.erl
+++ b/src/chttpd/src/chttpd_misc.erl
@@ -50,6 +50,7 @@ handle_welcome_req(#httpd{method='GET'}=Req, WelcomeMessage) ->
         {couchdb, WelcomeMessage},
         {version, list_to_binary(couch_server:get_version())},
         {git_sha, list_to_binary(couch_server:get_git_sha())},
+        {uuid, couch_server:get_uuid()},
         {features, config:features()}
         ] ++ case config:get("vendor") of
         [] ->
diff --git a/src/chttpd/test/chttpd_welcome_test.erl b/src/chttpd/test/chttpd_welcome_test.erl
index b737abd..e427f4d 100644
--- a/src/chttpd/test/chttpd_welcome_test.erl
+++ b/src/chttpd/test/chttpd_welcome_test.erl
@@ -45,12 +45,30 @@ welcome_test_() ->
                 fun setup/0, fun teardown/1,
                 [
                     fun should_have_version/1,
-                    fun should_have_features/1
+                    fun should_have_features/1,
+                    fun should_have_uuid/1
                 ]
             }
         }
     }.
 
+should_have_uuid(Url) ->
+    ?_test(begin
+        {ok, Status, _, Body} = test_request:get(Url, [?CONTENT_JSON, ?AUTH]),
+        ?assertEqual(200, Status),
+        {Json} = ?JSON_DECODE(Body),
+        CouchDB = couch_util:get_value(<<"couchdb">>, Json, undefined),
+        Uuid = couch_util:get_value(<<"uuid">>, Json, undefined),
+        Features = couch_util:get_value(<<"features">>, Json, undefined),
+        Sha = couch_util:get_value(<<"git_sha">>, Json, undefined),
+        ?assertNotEqual(Sha, undefined),
+        ?assertEqual(<<"Welcome">>, CouchDB),
+        RealUuid = couch_server:get_uuid(),
+
+        ?assertEqual(RealUuid, Uuid),
+        ?assert(is_list(Features))
+    end).
+
 
 should_have_version(Url) ->
     ?_test(begin