forked from tomekw/hikari-cp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add is-closed? and is-running? functions
Plus a bunch of improvements: - Closes tomekw#97 - A proper connection test with H2 - Updated documentation to use `next.jdbc`
- Loading branch information
1 parent
002c252
commit dbc3dee
Showing
5 changed files
with
135 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(ns hikari-cp.connection-test | ||
(:require | ||
[expectations :refer [expect]] | ||
[hikari-cp.core :as hikari-cp] | ||
[next.jdbc :as jdbc])) | ||
|
||
(let [pool (hikari-cp/make-datasource {:adapter "h2" | ||
:url "jdbc:h2:mem:test" | ||
;; :register-mbeans true | ||
;; :connection-timeout 1000 | ||
;; :connection-test-query "select 0" | ||
})] | ||
|
||
(with-open [connection (jdbc/get-connection pool {})] | ||
(let [result (jdbc/execute-one! connection ["select 1 as count"])] | ||
(expect {:COUNT 1} result))) | ||
|
||
;; NOTE: | ||
;; can't do this: (expect true (hikari-cp/is-running? pool)) | ||
;; most likely due to how expectations works | ||
(let [running? (hikari-cp/is-running? pool) | ||
closed? (hikari-cp/is-closed? pool)] | ||
(expect true running?) | ||
(expect false closed?)) | ||
|
||
(hikari-cp/close-datasource pool) | ||
|
||
(let [running? (hikari-cp/is-running? pool) | ||
closed? (hikari-cp/is-closed? pool)] | ||
|
||
(expect false running?) | ||
(expect true closed?))) |
Oops, something went wrong.