Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added test for Accept header example.

  • Loading branch information...
commit b0be96798cf7a09a1dc8e592af2ee48d734b02bc 1 parent a6d1a5b
Knut Nesheim authored March 27, 2013

Showing 1 changed file with 9 additions and 0 deletions. Show diff stats Hide diff stats

  1. 9  test/elli_tests.erl
9  test/elli_tests.erl
@@ -14,6 +14,7 @@ elli_test_() ->
14 14
       ?_test(crash()),
15 15
       ?_test(no_compress()),
16 16
       ?_test(exception_flow()),
  17
+      ?_test(accept_content_type()),
17 18
       ?_test(user_connection()),
18 19
       ?_test(get_args()),
19 20
       ?_test(post_args()),
@@ -95,6 +96,14 @@ exception_flow() ->
95 96
                   {"content-length", "9"}], headers(Response)),
96 97
     ?assertEqual("Forbidden", body(Response)).
97 98
 
  99
+accept_content_type() ->
  100
+    {ok, Json} = httpc:request(get, {"http://localhost:3001/type?name=knut",
  101
+                                     [{"Accept", "application/json"}]}, [], []),
  102
+    ?assertEqual(<<"{\"name\" : \"knut\"}">>, list_to_binary(body(Json))),
  103
+    {ok, Text} = httpc:request(get, {"http://localhost:3001/type?name=knut",
  104
+                                     [{"Accept", "text/plain"}]}, [], []),
  105
+    ?assertEqual("name: knut", body(Text)).
  106
+
98 107
 user_connection() ->
99 108
     {ok, Response} = httpc:request("http://localhost:3001/user/defined/behaviour"),
100 109
     ?assertEqual(304, status(Response)),

0 notes on commit b0be967

Please sign in to comment.
Something went wrong with that request. Please try again.