Skip to content

Commit

Permalink
bump dependencies; remove promesa; close threadpool in test
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarroway committed Jun 29, 2024
1 parent 251c66f commit f740aa7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Change Log
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).

## [Unreleased]
### Changed
- updated various dev dependencies

### Fixed
- shutdown threadpool in custom executor test so test finishes cleanly

## [0.9.0]
### Added
- deps.edn support - thanks @chrisbetz (#48)
Expand Down
3 changes: 1 addition & 2 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
:aliases {:test {:extra-paths ["test"]
:extra-deps {ring/ring-core {:mvn/version "1.9.5"}
javax.servlet/servlet-api {:mvn/version "2.5"}
funcool/promesa {:mvn/version "8.0.446"}
cheshire/cheshire {:mvn/version "5.10.2"}
com.cognitect/transit-clj {:mvn/version "0.8.319"}
http-kit/http-kit {:mvn/version "2.6.0"}
io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "48c3c67"}}
{:git/tag "v0.5.1" :git/sha "dfb30dd"}}
:exec-fn cognitect.test-runner.api/test}}}
9 changes: 4 additions & 5 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
:sign-releases false}]]
:plugins [[lein-cljfmt "0.6.4"]]
:global-vars {*warn-on-reflection* true}
:profiles {:dev {:dependencies [[org.clojure/clojure "1.10.1"]
[cheshire "5.10.0"]
[ring/ring-core "1.9.0"]
:profiles {:dev {:dependencies [[org.clojure/clojure "1.11.1"]
[cheshire "5.10.2"]
[ring/ring-core "1.9.5"]
[javax.servlet/servlet-api "2.5"]
[com.cognitect/transit-clj "0.8.319"]
[funcool/promesa "6.0.0"]
[http-kit "2.3.0"]]}})
[http-kit "2.6.0"]]}})
17 changes: 10 additions & 7 deletions test/hato/client_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
[org.httpkit.server :as http-kit]
[cheshire.core :as json]
[cognitect.transit :as transit]
[promesa.exec :as pexec]
[ring.middleware.multipart-params])
(:import (java.io InputStream ByteArrayOutputStream)
(java.net ProxySelector CookieHandler CookieManager)
(java.net.http HttpClient$Redirect HttpClient$Version HttpClient)
(java.time Duration)
(javax.net.ssl SSLContext)
(java.util UUID)))
(java.util UUID)
(java.util.concurrent Executors)))

(defmacro with-server
"Spins up a local HTTP server with http-kit."
[handler & body]
`(let [s# (http-kit/run-server ~handler {:port 1234})]
`(let [s# (http-kit/run-server ~handler {:port 1234 :legacy-return-value? false})]
(try ~@body
(finally
(s# :timeout 100)))))
(http-kit/server-stop! s#)))))

(deftest test-build-http-client
(testing "authenticator"
Expand Down Expand Up @@ -72,7 +72,7 @@
(is (.isPresent (.proxy (build-http-client {:proxy (ProxySelector/getDefault)})))))

(testing "executor"
(let [executor (pexec/fixed-pool 1)
(let [executor (Executors/newFixedThreadPool 1)
client (build-http-client {:executor executor})
stored-executor (.orElse (.executor client) nil)]
(is (instance? java.util.concurrent.ThreadPoolExecutor stored-executor) "executor has proper type")
Expand Down Expand Up @@ -103,9 +103,12 @@
(is (= "gzip, deflate" (get-in r [:request :headers "accept-encoding"])))))

(testing "setting executor works"
(let [c (build-http-client {:executor (pexec/fixed-pool 1)})
(let [e (Executors/newFixedThreadPool 1)
c (build-http-client {:executor e})
r (get "https://httpbin.org/get" {:http-client c})]
(is (= 200 (:status r)))))
(try
(is (= 200 (:status r)))
(finally (.shutdownNow e)))))

(testing "query encoding"
(let [r (get "https://httpbin.org/get?foo=bar<bee")]
Expand Down

0 comments on commit f740aa7

Please sign in to comment.