Github user nickva commented on a diff in the pull request:
https://github.com/apache/couchdb-couch-mrview/pull/29#discussion_r40431604
--- Diff: test/couch_mrview_http_tests.erl ---
@@ -0,0 +1,43 @@
+% 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_mrview_http_tests).
+
+-include_lib("couch/include/couch_eunit.hrl").
+-include_lib("couch_mrview/include/couch_mrview.hrl").
+
+
+mrview_http_test_() ->
+ [
+ ?_assertEqual(#mrargs{group_level=exact}, parse_group("true")),
+ ?_assertEqual(#mrargs{group_level=1}, parse_level("1")),
+ ?_assertEqual(#mrargs{group_level=0}, parse_level("0")),
+ ?_assertEqual(#mrargs{group_level=1},
parse_group_and_level("true", "1")),
+ ?_assertEqual(#mrargs{group_level=0},
parse_group_and_level("false", "0")),
+ ?_assertEqual(#mrargs{group_level=0},
parse_group_and_level("true", "0")),
+ ?_assertEqual(#mrargs{group_level=0}, parse_group("false")),
+ ?_assertThrow({query_parse_error,
+ <<"Can't specify group=false and group_level>0 at the same
time">>},
+ parse_group_and_level("false", "1"))
+ ].
+
+
+parse_group(Group) ->
+ couch_mrview_http:parse_params([{"group", Group}], undefined,
#mrargs{}).
+
+parse_level(GroupLevel)->
+ Params = [{"group_level", GroupLevel}],
+ couch_mrview_http:parse_params(Params, undefined, #mrargs{}).
+
+parse_group_and_level(Group, GroupLevel) ->
+ Params = [{"group", Group}, {"group_level", GroupLevel}],
--- End diff --
Good point. I'll add the tests. The reason was that due to how the check is
performed in code, order shouldn't matter. Sorting out the various combination
of values was the tricky part.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---