Skip to content

Commit 78329e9

Browse files
committed
Add test for unrecognized file in slurp
1 parent 8fc4596 commit 78329e9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

test/clj/cider/nrepl/middleware/slurp_test.clj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
(:require
33
[cider.nrepl.middleware.slurp :refer [if-class slurp-url-to-content+body]]
44
[clojure.java.io :as io]
5-
[clojure.test :as t]))
5+
[clojure.test :as t]
6+
[clojure.string :as str]))
67

78
;; FIXME (arrdem 2018-04-11):
89
;; Remove these if-classes when we have jdk1.8 min
@@ -22,3 +23,11 @@
2223
(io/resource "sum-types-are-cool.jpg")))]
2324
(t/is (= ["image/jpeg" {}] (:content-type resp)))
2425
(t/is (= "base64" (:content-transfer-encoding resp))))))
26+
27+
(if-class java.util.Base64
28+
(t/deftest test-unrecognized-file
29+
(let [resp (slurp-url-to-content+body
30+
(.toString (io/resource "unknown.bin")))]
31+
(t/is (= ["application/octet-stream" {}] (:content-type resp)))
32+
(t/is (str/starts-with? (:body resp) "#binary[location="))
33+
(t/is (str/ends-with? (:body resp) ",size=3]")))))

test/resources/unknown.bin

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo

0 commit comments

Comments
 (0)