|
56 | 56 | "[\"~#set\",[1,3,2]]],\"~:baz\",\"~f7\"," |
57 | 57 | "\"~:foo\",\"bar\"]") |
58 | 58 | :headers {"content-type" "application/transit+json"}} |
| 59 | + [:get "/transit-json-bad"] |
| 60 | + {:status 400 :body "[\"^ \", \"~:foo\",\"bar\"]"} |
| 61 | + [:get "/transit-json-empty"] |
| 62 | + {:status 200 |
| 63 | + :headers {"content-type" "application/transit+json"}} |
59 | 64 | [:get "/transit-msgpack"] |
60 | 65 | {:status 200 |
61 | 66 | :body (->> [-125 -86 126 58 101 103 103 112 108 97 110 116 -127 -90 126 |
|
338 | 343 | (run-server) |
339 | 344 | (let [transit-json-resp (client/get (localhost "/transit-json") {:as :auto}) |
340 | 345 | transit-msgpack-resp (client/get (localhost "/transit-msgpack") |
341 | | - {:as :auto})] |
| 346 | + {:as :auto}) |
| 347 | + bad-status-resp-default (client/get (localhost "/transit-json-bad") |
| 348 | + {:throw-exceptions false :as :transit+json}) |
| 349 | + bad-status-resp-always (client/get (localhost "/transit-json-bad") |
| 350 | + {:throw-exceptions false :as :transit+json |
| 351 | + :coerce :always}) |
| 352 | + bad-status-resp-exceptional (client/get (localhost "/transit-json-bad") |
| 353 | + {:throw-exceptions false :as :transit+json |
| 354 | + :coerce :exceptional}) |
| 355 | + empty-resp (client/get (localhost "/transit-json-empty") |
| 356 | + {:throw-exceptions false :as :transit+json})] |
342 | 357 | (is (= 200 |
343 | 358 | (:status transit-json-resp) |
344 | | - (:status transit-msgpack-resp))) |
| 359 | + (:status transit-msgpack-resp) |
| 360 | + (:status empty-resp))) |
| 361 | + (is (= 400 |
| 362 | + (:status bad-status-resp-default) |
| 363 | + (:status bad-status-resp-always) |
| 364 | + (:status bad-status-resp-exceptional))) |
345 | 365 | (is (= {:foo "bar" :baz 7M :eggplant {:quux #{1 2 3}}} |
346 | 366 | (:body transit-json-resp) |
347 | | - (:body transit-msgpack-resp))))) |
| 367 | + (:body transit-msgpack-resp))) |
| 368 | + |
| 369 | + (is (nil? (:body empty-resp))) |
| 370 | + |
| 371 | + (is (= "[\"^ \", \"~:foo\",\"bar\"]" |
| 372 | + (:body bad-status-resp-default))) |
| 373 | + (is (= {:foo "bar"} |
| 374 | + (:body bad-status-resp-always))) |
| 375 | + (is (= {:foo "bar"} |
| 376 | + (:body bad-status-resp-exceptional))))) |
348 | 377 |
|
349 | 378 | (deftest ^:integration t-json-output-coercion |
350 | 379 | (run-server) |
|
0 commit comments