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 2020/03/23 17:10:30 UTC

[GitHub] [couchdb] davisp commented on a change in pull request #2706: add info endpoint for fdb stored views

davisp commented on a change in pull request #2706: add info endpoint for fdb stored views
URL: https://github.com/apache/couchdb/pull/2706#discussion_r396613371
 
 

 ##########
 File path: src/couch_views/test/couch_views_info_test.erl
 ##########
 @@ -0,0 +1,134 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(couch_views_info_test).
+
+-include_lib("couch/include/couch_eunit.hrl").
+-include_lib("couch/include/couch_db.hrl").
+-include_lib("couch_mrview/include/couch_mrview.hrl").
+-include_lib("fabric/test/fabric2_test.hrl").
+
+-define(MAP_FUN1, <<"map_fun1">>).
+
+setup() ->
+    Ctx = test_util:start_couch([
+            fabric,
+            couch_jobs,
+            couch_js,
+            couch_views
+        ]),
+    Ctx.
+
+cleanup(Ctx) ->
+    test_util:stop_couch(Ctx).
+
+foreach_setup() ->
+    {ok, Db} = fabric2_db:create(?tempdb(), [{user_ctx, ?ADMIN_USER}]),
+    DDoc = create_ddoc(),
+    Doc1 = doc(0, 1),
+
+    {ok, _} = fabric2_db:update_doc(Db, DDoc, []),
+    {ok, _} = fabric2_db:update_doc(Db, Doc1, []),
+
+    run_query(Db, DDoc, ?MAP_FUN1),
+    {ok, Info} = couch_views:get_info(Db, DDoc),
+    {Db, Info}.
+
+foreach_teardown({Db, _}) ->
+    meck:unload(),
+    ok = fabric2_db:delete(fabric2_db:name(Db), []).
+
+views_info_test_() ->
+    {
+        "Views index info test",
+        {
+            setup,
+            fun setup/0,
+            fun cleanup/1,
+            {
+                foreach,
+                fun foreach_setup/0,
+                fun foreach_teardown/1,
+                [
+                    fun sig_is_binary/1,
+                    fun language_is_js/1,
+                    fun update_seq_is_binary/1,
+                    fun updater_running_is_boolean/1,
+                    fun data_size_is_non_neg_int/1,
+                    fun active_size_is_non_neg_int/1,
+                    fun update_opts_is_bin_list/1
+                ]
+            }
+        }
+    }.
+
+sig_is_binary({_, Info}) ->
+    ?_assert(is_binary(prop(signature, Info))).
+
+language_is_js({_, Info}) ->
+    ?_assertEqual(<<"javascript">>, prop(language, Info)).
+
+data_size_is_non_neg_int({_, Info}) ->
+    ?_assert(check_non_neg_int(data_size, Info)).
 
 Review comment:
   This should fail, right?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services