|
282 | 282 | (is (:pp-stacktrace response))))) |
283 | 283 |
|
284 | 284 | (testing "inspect-set-page-size error handling" |
285 | | - (with-redefs [i/swap-inspector! (fn [& _] (throw (Exception. "page-size exception")))] |
286 | | - (let [response (session/message {:op "inspect-set-page-size" :page-size 10})] |
287 | | - (is (= (:status response) #{"inspect-set-page-size-error" "done"})) |
288 | | - (is (= (:ex response) "class java.lang.Exception")) |
289 | | - (is (-> response ^String (:err) (.startsWith "java.lang.Exception: page-size exception"))) |
290 | | - (is (:pp-stacktrace response))))) |
| 285 | + (let [response (session/message {:op "inspect-set-page-size" :page-size 0})] |
| 286 | + (is (= #{"inspect-set-page-size-error" "done"} (:status response))) |
| 287 | + (is (= "class clojure.lang.ExceptionInfo" (:ex response))) |
| 288 | + (is (match? #".*Precondition failed: \(pos-int\? page-size\).*" (:err response))) |
| 289 | + (is (:pp-stacktrace response))) |
| 290 | + |
| 291 | + (let [response (session/message {:op "inspect-refresh" :page-size 0})] |
| 292 | + (is (= #{"inspect-refresh-error" "done"} (:status response))) |
| 293 | + (is (= "class clojure.lang.ExceptionInfo" (:ex response))) |
| 294 | + (is (match? #".*Precondition failed: \(pos-int\? page-size\).*" (:err response))) |
| 295 | + (is (:pp-stacktrace response)))) |
291 | 296 |
|
292 | 297 | (testing "inspect-set-max-atom-length error handling" |
293 | | - (with-redefs [i/swap-inspector! (fn [& _] (throw (Exception. "max-atom-length exception")))] |
294 | | - (let [response (session/message {:op "inspect-set-max-atom-length" :max-atom-length 10})] |
295 | | - (is (= (:status response) #{"inspect-set-max-atom-length-error" "done"})) |
296 | | - (is (= (:ex response) "class java.lang.Exception")) |
297 | | - (is (-> response ^String (:err) (.startsWith "java.lang.Exception: max-atom-length exception"))) |
298 | | - (is (:pp-stacktrace response))))) |
| 298 | + (let [response (session/message {:op "inspect-set-max-atom-length" :max-atom-length 0})] |
| 299 | + (is (= #{"inspect-set-max-atom-length-error" "done"} (:status response))) |
| 300 | + (is (= "class clojure.lang.ExceptionInfo" (:ex response))) |
| 301 | + (is (match? #".*Precondition failed: \(pos-int\? max-atom-length\).*" (:err response))) |
| 302 | + (is (:pp-stacktrace response))) |
| 303 | + |
| 304 | + (let [response (session/message {:op "inspect-refresh" :max-atom-length 0})] |
| 305 | + (is (= #{"inspect-refresh-error" "done"} (:status response))) |
| 306 | + (is (= "class clojure.lang.ExceptionInfo" (:ex response))) |
| 307 | + (is (match? #".*Precondition failed: \(pos-int\? max-atom-length\).*" (:err response))) |
| 308 | + (is (:pp-stacktrace response)))) |
299 | 309 |
|
300 | 310 | (testing "inspect-set-max-coll-size error handling" |
301 | | - (with-redefs [i/swap-inspector! (fn [& _] (throw (Exception. "max-coll-size exception")))] |
302 | | - (let [response (session/message {:op "inspect-set-max-coll-size" :max-coll-size 10})] |
303 | | - (is (= (:status response) #{"inspect-set-max-coll-size-error" "done"})) |
304 | | - (is (= (:ex response) "class java.lang.Exception")) |
305 | | - (is (-> response ^String (:err) (.startsWith "java.lang.Exception: max-coll-size exception"))) |
306 | | - (is (:pp-stacktrace response)))))) |
| 311 | + (let [response (session/message {:op "inspect-set-max-coll-size" :max-coll-size 0})] |
| 312 | + (is (= #{"inspect-set-max-coll-size-error" "done"} (:status response))) |
| 313 | + (is (= "class clojure.lang.ExceptionInfo" (:ex response))) |
| 314 | + (is (match? #".*Precondition failed: \(pos-int\? max-coll-size\).*" (:err response))) |
| 315 | + (is (:pp-stacktrace response))) |
| 316 | + |
| 317 | + (let [response (session/message {:op "inspect-refresh" :max-coll-size 0})] |
| 318 | + (is (= #{"inspect-refresh-error" "done"} (:status response))) |
| 319 | + (is (= "class clojure.lang.ExceptionInfo" (:ex response))) |
| 320 | + (is (match? #".*Precondition failed: \(pos-int\? max-coll-size\).*" (:err response))) |
| 321 | + (is (:pp-stacktrace response))))) |
307 | 322 |
|
308 | 323 | (deftest inspect-var-integration-test |
309 | 324 | (testing "rendering a var" |
|
367 | 382 | (session/message {:op "eval" |
368 | 383 | :inspect "true" |
369 | 384 | :code "(map identity (range 35))"}) |
370 | | - (session/message {:op "inspect-set-page-size" |
| 385 | + (session/message {:op "inspect-refresh" |
371 | 386 | :page-size 5}) |
372 | 387 | (session/message {:op "inspect-next-page"}) |
373 | 388 | (session/message {:op "inspect-prev-page"}))))))) |
|
473 | 488 | (is (re-find #"Page size: 5, showing page: 2 of 20" |
474 | 489 | (extract-text small-page-2))))) |
475 | 490 |
|
476 | | - (testing "page size can be changed via the inspect-set-page-size op" |
| 491 | + (testing "page size can be changed via the inspect-refresh op" |
477 | 492 | (session/message {:op "inspect-clear"}) |
478 | 493 | (let [normal-page-size (session/message {:op "eval" |
479 | 494 | :inspect "true" |
480 | 495 | :code "(range 100)"}) |
481 | 496 | normal-page-2 (session/message {:op "inspect-next-page"}) |
482 | 497 |
|
483 | | - small-page-size (session/message {:op "inspect-set-page-size" |
| 498 | + small-page-size (session/message {:op "inspect-refresh" |
484 | 499 | :page-size 5}) |
485 | 500 | small-page-2 (session/message {:op "inspect-next-page"}) |
486 | 501 |
|
|
535 | 550 | :code too-long}) |
536 | 551 | extract-text) |
537 | 552 | (x-pattern max-len "..."))) |
538 | | - (is (string/includes? (-> (session/message {:op "inspect-set-max-atom-length" |
| 553 | + (is (string/includes? (-> (session/message {:op "inspect-refresh" |
539 | 554 | :max-atom-length 10}) |
540 | 555 | extract-text) |
541 | 556 | (x-pattern 10 "..."))) |
542 | | - (is (string/includes? (-> (session/message {:op "inspect-set-max-atom-length" |
| 557 | + (is (string/includes? (-> (session/message {:op "inspect-refresh" |
543 | 558 | :max-atom-length 20}) |
544 | 559 | extract-text) |
545 | 560 | (x-pattern 20 "...")))))) |
|
548 | 563 | (let [max-len (:max-value-length @#'orchard.inspect/default-inspector-config) |
549 | 564 | extract-text #(-> % :value first)] |
550 | 565 |
|
551 | | - ;; TODO: reduce leeway once orchard.print truncation is fixed |
552 | 566 | (testing "max value length can be set for the eval op" |
553 | | - (is (< (- max-len 10) |
| 567 | + (is (< max-len |
554 | 568 | (-> (session/message {:op "eval" |
555 | 569 | :inspect "true" |
556 | 570 | :code infinite-map-code}) |
557 | 571 | extract-text |
558 | 572 | count) |
559 | | - (+ max-len 2000))) |
560 | | - (is (< 490 |
| 573 | + (+ max-len 300))) |
| 574 | + (is (< 500 |
561 | 575 | (-> (session/message {:op "eval" |
562 | 576 | :inspect "true" |
563 | 577 | :code infinite-map-code |
|
599 | 613 | (let [default-coll-size (session/message {:op "eval" |
600 | 614 | :inspect "true" |
601 | 615 | :code big-coll}) |
602 | | - large-coll-size (session/message {:op "inspect-set-max-coll-size" |
| 616 | + large-coll-size (session/message {:op "inspect-refresh" |
603 | 617 | :max-coll-size big-size}) |
604 | | - smaller-coll-size (session/message {:op "inspect-set-max-coll-size" |
| 618 | + smaller-coll-size (session/message {:op "inspect-refresh" |
605 | 619 | :max-coll-size (dec big-size)}) |
606 | 620 | unchanged-default-coll-size (do (session/message {:op "inspect-clear"}) |
607 | 621 | (session/message {:op "eval" |
|
638 | 652 | (let [default (session/message {:op "eval" |
639 | 653 | :inspect "true" |
640 | 654 | :code nested-coll}) |
641 | | - limited (session/message {:op "inspect-set-max-nested-depth" |
| 655 | + limited (session/message {:op "inspect-refresh" |
642 | 656 | :max-nested-depth 5})] |
643 | 657 | (is (string/includes? (extract-text default) |
644 | 658 | "\"[ [ [ [ [ [ [ [ [ [ 1 ] ] ] ] ] ] ] ] ] ]\"")) |
|
0 commit comments