|
203 | 203 | (.toInstant java.time.ZoneOffset/UTC)
|
204 | 204 | (java.time.Clock/fixed (java.time.ZoneId/systemDefault))))
|
205 | 205 |
|
206 |
| -(defn trace-str [lines] |
| 206 | +(defn trace-log [lines] |
207 | 207 | [:debug (string/join "\n" (into lines ["" "" ""]))])
|
208 | 208 |
|
209 | 209 | (deftest should-trace-received-notifications
|
|
216 | 216 | trace-ch (:trace-ch server)]
|
217 | 217 | (server/start server nil)
|
218 | 218 | (async/put! input-ch (messages/request "foo" {:result "body"}))
|
219 |
| - (is (= (trace-str ["[Trace - 2022-03-05T13:35:23Z] Received notification 'foo'" |
| 219 | + (is (= (trace-log ["[Trace - 2022-03-05T13:35:23Z] Received notification 'foo'" |
220 | 220 | "Params: {"
|
221 | 221 | " \"result\" : \"body\""
|
222 | 222 | "}"])
|
|
233 | 233 | trace-ch (:trace-ch server)]
|
234 | 234 | (server/start server nil)
|
235 | 235 | (async/put! input-ch (messages/request 1 "foo" {:result "body"}))
|
236 |
| - (is (= (trace-str ["[Trace - 2022-03-05T13:35:23Z] Received request 'foo - (1)'" |
| 236 | + (is (= (trace-log ["[Trace - 2022-03-05T13:35:23Z] Received request 'foo - (1)'" |
237 | 237 | "Params: {"
|
238 | 238 | " \"result\" : \"body\""
|
239 | 239 | "}"])
|
240 | 240 | (h/assert-take trace-ch)))
|
241 |
| - (is (= (trace-str ["[Trace - 2022-03-05T13:35:23Z] Sending response 'foo - (1)'. Request took 0ms. Request failed: Method not found (-32601)." |
| 241 | + (is (= (trace-log ["[Trace - 2022-03-05T13:35:23Z] Sending response 'foo - (1)'. Request took 0ms. Request failed: Method not found (-32601)." |
242 | 242 | "Error data: {"
|
243 | 243 | " \"method\" : \"foo\""
|
244 | 244 | "}"])
|
|
256 | 256 | _ (server/start server nil)
|
257 | 257 | _ (server/send-request server "req" {:body "foo"})
|
258 | 258 | client-rcvd-msg (h/assert-take output-ch)]
|
259 |
| - (is (= (trace-str ["[Trace - 2022-03-05T13:35:23Z] Sending request 'req - (1)'" |
| 259 | + (is (= (trace-log ["[Trace - 2022-03-05T13:35:23Z] Sending request 'req - (1)'" |
260 | 260 | "Params: {"
|
261 | 261 | " \"body\" : \"foo\""
|
262 | 262 | "}"])
|
263 | 263 | (h/assert-take trace-ch)))
|
264 | 264 | (async/put! input-ch (messages/response (:id client-rcvd-msg) {:processed true}))
|
265 |
| - (is (= (trace-str ["[Trace - 2022-03-05T13:35:23Z] Received response 'req - (1)'. Request took 0ms." |
| 265 | + (is (= (trace-log ["[Trace - 2022-03-05T13:35:23Z] Received response 'req - (1)'. Request took 0ms." |
266 | 266 | "Result: {"
|
267 | 267 | " \"processed\" : true"
|
268 | 268 | "}"])
|
|
280 | 280 | _ (server/start server nil)
|
281 | 281 | _ (server/send-request server "req" {:body "foo"})
|
282 | 282 | client-rcvd-msg (h/assert-take output-ch)]
|
283 |
| - (is (= (trace-str ["[Trace - 2022-03-05T13:35:23Z] Sending request 'req - (1)'" |
| 283 | + (is (= (trace-log ["[Trace - 2022-03-05T13:35:23Z] Sending request 'req - (1)'" |
284 | 284 | "Params: {"
|
285 | 285 | " \"body\" : \"foo\""
|
286 | 286 | "}"])
|
287 | 287 | (h/assert-take trace-ch)))
|
288 | 288 | (async/put! input-ch
|
289 | 289 | (messages/response (:id client-rcvd-msg)
|
290 | 290 | {:error {:code 1234 :message "Something bad" :data {:body "foo"}}}))
|
291 |
| - (is (= (trace-str ["[Trace - 2022-03-05T13:35:23Z] Received response 'req - (1)'. Request took 0ms. Request failed: Something bad (1234)." |
| 291 | + (is (= (trace-log ["[Trace - 2022-03-05T13:35:23Z] Received response 'req - (1)'. Request took 0ms. Request failed: Something bad (1234)." |
292 | 292 | "Error data: {"
|
293 | 293 | " \"body\" : \"foo\""
|
294 | 294 | "}"])
|
|
305 | 305 | trace-ch (:trace-ch server)]
|
306 | 306 | (server/start server nil)
|
307 | 307 | (async/put! input-ch (messages/response 100 {:processed true}))
|
308 |
| - (is (= (trace-str ["[Trace - 2022-03-05T13:35:23Z] Received response for unmatched request:" |
| 308 | + (is (= (trace-log ["[Trace - 2022-03-05T13:35:23Z] Received response for unmatched request:" |
309 | 309 | "Body: {"
|
310 | 310 | " \"jsonrpc\" : \"2.0\","
|
311 | 311 | " \"id\" : 100,"
|
|
326 | 326 | trace-ch (:trace-ch server)]
|
327 | 327 | (server/start server nil)
|
328 | 328 | (server/send-notification server "req" {:body "foo"})
|
329 |
| - (is (= (trace-str ["[Trace - 2022-03-05T13:35:23Z] Sending notification 'req'" |
| 329 | + (is (= (trace-log ["[Trace - 2022-03-05T13:35:23Z] Sending notification 'req'" |
330 | 330 | "Params: {"
|
331 | 331 | " \"body\" : \"foo\""
|
332 | 332 | "}"])
|
|
432 | 432 | :clock fixed-clock})]
|
433 | 433 | (server/start server nil)
|
434 | 434 | (async/put! input-ch (messages/request "foo" {:result "body"}))
|
435 |
| - (is (= (trace-str ["[Trace - 2022-03-05T13:35:23Z] Received notification 'foo'" |
| 435 | + (is (= (trace-log ["[Trace - 2022-03-05T13:35:23Z] Received notification 'foo'" |
436 | 436 | "Params: {"
|
437 | 437 | " \"result\" : \"body\""
|
438 | 438 | "}"])
|
|
0 commit comments