summaryrefslogtreecommitdiff
path: root/src/chttpd/test/eunit/chttpd_prefer_header_test.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/chttpd/test/eunit/chttpd_prefer_header_test.erl')
-rw-r--r--src/chttpd/test/eunit/chttpd_prefer_header_test.erl37
1 files changed, 12 insertions, 25 deletions
diff --git a/src/chttpd/test/eunit/chttpd_prefer_header_test.erl b/src/chttpd/test/eunit/chttpd_prefer_header_test.erl
index 1b1195418..55c9f350e 100644
--- a/src/chttpd/test/eunit/chttpd_prefer_header_test.erl
+++ b/src/chttpd/test/eunit/chttpd_prefer_header_test.erl
@@ -17,52 +17,46 @@
-include_lib("couch/include/couch_db.hrl").
-include_lib("eunit/include/eunit.hrl").
-
mock_request(ExcludeHeader) ->
Headers = mochiweb_headers:make(ExcludeHeader),
MochiReq = mochiweb_request:new(nil, 'GET', "/", {1, 1}, Headers),
MochiReq:cleanup(),
#httpd{mochi_req = MochiReq}.
-
default_headers() ->
[
- {"Cache-Control","must-revalidate"},
- {"Content-Type","application/json"},
+ {"Cache-Control", "must-revalidate"},
+ {"Content-Type", "application/json"},
{"Content-Length", "100"},
- {"ETag","\"12343\""},
- {"X-Couch-Request-ID","7bd1adab86"},
- {"X-CouchDB-Body-Time","0"},
+ {"ETag", "\"12343\""},
+ {"X-Couch-Request-ID", "7bd1adab86"},
+ {"X-CouchDB-Body-Time", "0"},
{"Vary", "Accept-Encoding"},
- {"Server","CouchDB/2.1.0-f1a1d7f1c (Erlang OTP/19)"}
+ {"Server", "CouchDB/2.1.0-f1a1d7f1c (Erlang OTP/19)"}
].
-
minimal_options_headers() ->
[
- {"Cache-Control","must-revalidate"},
- {"Content-Type","application/json"},
+ {"Cache-Control", "must-revalidate"},
+ {"Content-Type", "application/json"},
{"Content-Length", "100"},
- {"ETag","\"12343\""},
+ {"ETag", "\"12343\""},
{"Vary", "Accept-Encoding"},
- {"Server","CouchDB/2.1.0-f1a1d7f1c (Erlang OTP/19)"}
+ {"Server", "CouchDB/2.1.0-f1a1d7f1c (Erlang OTP/19)"}
].
-
default_no_exclude_header_test() ->
Headers = chttpd_prefer_header:maybe_return_minimal(
mock_request([]),
default_headers()
- ),
+ ),
?assertEqual(default_headers(), Headers).
-
unsupported_exclude_header_test() ->
Req = mock_request([{"prefer", "Wrong"}]),
Headers = chttpd_prefer_header:maybe_return_minimal(Req, default_headers()),
?assertEqual(default_headers(), Headers).
-
empty_header_test() ->
Req = mock_request([{"prefer", ""}]),
Headers = chttpd_prefer_header:maybe_return_minimal(Req, default_headers()),
@@ -70,24 +64,20 @@ empty_header_test() ->
setup_all() ->
ok = meck:new(config),
- ok = meck:expect(config, get, fun("chttpd", "prefer_minimal", _) ->
+ ok = meck:expect(config, get, fun("chttpd", "prefer_minimal", _) ->
"Cache-Control, Content-Length, Content-Type, ETag, Server, Vary"
end),
ok.
-
teardown_all(_) ->
meck:unload().
-
setup() ->
meck:reset([config]).
-
teardown(_) ->
ok.
-
exclude_headers_test_() ->
{
"Test Prefer headers",
@@ -108,19 +98,16 @@ exclude_headers_test_() ->
}
}.
-
minimal_options(_) ->
Req = mock_request([{"Prefer", "return=minimal"}]),
Headers = chttpd_prefer_header:maybe_return_minimal(Req, default_headers()),
?_assertEqual(minimal_options_headers(), Headers).
-
minimal_options_check_header_case(_) ->
Req = mock_request([{"prefer", "return=minimal"}]),
Headers = chttpd_prefer_header:maybe_return_minimal(Req, default_headers()),
?_assertEqual(minimal_options_headers(), Headers).
-
minimal_options_check_header_value_case(_) ->
Req = mock_request([{"prefer", "RETURN=MINIMAL"}]),
Headers = chttpd_prefer_header:maybe_return_minimal(Req, default_headers()),