Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-chttpd/pull/9#discussion_r20598233
  
    --- Diff: test/chttpd_db_test.erl ---
    @@ -0,0 +1,58 @@
    +% 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(chttpd_db_test).
    +
    +-include_lib("couch/include/couch_eunit.hrl").
    +-include_lib("couch/include/couch_db.hrl").
    +
    +-define(TIMEOUT, 1000).
    +
    +setup() ->
    +    Cmd = "../../../dev/run",
    +    TmpDb = ?b2l(?tempdb()),
    +    Config = filename:join([?BUILDDIR(), "dev", "lib", "node1", "etc", 
"default.ini"]),
    +    {ok, _Pid} = config:start_link([Config]),
    +    Url = lists:concat(["http://";, config:get("httpd", "bind_address"), 
":", config:get("chttpd", "port"), "/", TmpDb]),
    +    {erlang:open_port({spawn, Cmd}, [exit_status]), Url}.
    +
    +teardown({Port, Url}) ->
    +    {ok, _Code, _Headers, _Body} = test_request:delete(Url),
    +    config:stop(),
    +    port_close(Port),
    +    ok.
    +
    +all_test_() ->
    +    {
    +        foreach,
    +        fun setup/0, fun teardown/1,
    +        [
    +            fun should_return_ok_true_on_bulk_update/1
    +        ]
    +    }.
    +
    +
    +should_return_ok_true_on_bulk_update({_Port, Url}) ->
    +    ?_assertEqual(true,
    +        begin
    +            {ok, _, _, _} = test_request:delete(Url),
    +            {ok, _, _, _} = test_request:put(Url, ""),
    +            {ok, _, _, Body} = test_request:put(Url ++ "/testdoc",
    +                [{"Content-Type", "application/json"}], "{}"),
    +            Json = jiffy:decode(Body),
    +            Ref = proplists:get_value(<<"rev">>, element(1, Json)),
    +            NewDoc = "{\"docs\": [{\"_rev\": \"" ++ ?b2l(Ref) ++ "\", 
\"_id\": \"testdoc\"}]}",
    +            {ok, _, _, ResultBody} = test_request:post(Url ++ 
"/_bulk_docs/",
    +                [{"Content-Type", "application/json"}], NewDoc),
    +            ?debugFmt("~s", [?b2l(ResultBody)]),
    +            string:str(?b2l(ResultBody), "\"ok\":true") > 0
    --- End diff --
    
    AS I wrote in the description:
    
    The tests are separated and are quite funky. The main
    reason why I also submit them is to get some 
    opinions and maybe a discussion about 
    integration-tests for couchdb-chttpd running.
    
    I could imagine something based on Erlang to test 
    chttpd which has better quality than my code.
    
    Another solution would be something JS/node based,
    I am more used to that and faster in writing JS, but it
    may not apply to everyone
    
    Use a complete different language / solution to test
    
    
    I also forgot to mention that they just work after the second run as the 
port is not working very well. TBH I don't expect them to land.


---
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.
---

Reply via email to