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

    https://github.com/apache/couchdb-couch/pull/55#discussion_r31046557
  
    --- Diff: test/couch_httpd_headers_tests.erl ---
    @@ -0,0 +1,55 @@
    +% 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_httpd_headers_tests).
    +
    +-include_lib("couch/include/couch_eunit.hrl").
    +
    +add_header_if_needed_test() ->
    +    Cases = [
    +        % should add to empty headers list
    +        {[],                           {"K1", "V1"}, [{"K1", "V1"}]},
    +        % should add to non-empty header_list
    +        {[{"K1", "V1"}],               {"K2", "V2"}, [{"K1", "V1"}, {"K2", 
"V2"}]},
    +         % should not add or change when already there
    +        {[{"K1", "V1"}],               {"K1", "V2"}, [{"K1", "V1"}]},
    +         % should not add or change when already there
    +        {[{"K1", "V1"}, {"K2", "V2"}], {"K1", "V2"}, [{"K1", "V1"}, {"K2", 
"V2"}]},
    +        % should add to a bit longer list
    +        {[{"K1", "V1"}, {"K2", "V2"}], {"K3", "V3"}, [{"K1", "V1"}, {"K2", 
"V2"}, {"K3", "V3"}]} 
    +    ],
    +    lists:map(fun({InitialHeaders, HeaderToAdd, ProperResult}) ->
    +        ?assertEqual(ProperResult, 
couch_httpd:add_header_if_needed(HeaderToAdd, InitialHeaders))
    +    end, Cases).
    +    
    +add_default_headers_if_needed_test() ->
    +    % couch_httpd uses process dictionary to check if currently in a 
    +    % json serving method. Defaults to 'application/javascript' otherwise.
    +    % In this test, with an empty dummy request it will also default to 
that.
    +    DummyRequest = [],
    +    NoCacheHeader = {"Cache-Control", "no-cache"},
    +    DefaultMustRevalidateHeader = {"Cache-Control", "must-revalidate"}, 
    +    DefaultApplicationJavascriptHeader = {"Content-Type", 
"application/javascript"},
    +    ApplicationJsonHeader = {"Content-Type", "application/json"},
    +    Cases = [
    +        % When there are no headers should add Content-Type and 
Cache-Control
    +        {[],                                     
[DefaultApplicationJavascriptHeader, DefaultMustRevalidateHeader]},
    --- End diff --
    
    Can we not go beyond from 80 right margin?


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