Compare commits

...

20 commits
0.7.0 ... main

Author SHA1 Message Date
Eddú Meléndez Gonzales
802f18af55
Update GHA versions (#80)
* actions/setup-java@v4
* actions/cache@v4
* actions/checkout@v4
2024-04-16 07:53:09 -05:00
Tim Zöller
1297054b77 Updated dependency versions 2024-04-13 09:32:57 +02:00
Tim Zöller
233c3883eb
Make config clearer in log-strategies.md (#73) (#77)
This wasn't working for me because nothing in here says it all needs to be the value a `:log-to` key in the container config map. Reading the code and adding that made it work. Figured it might be nice to clarify that for others too.

Co-authored-by: Wes Morgan <github@wesmorgan.me>
2024-04-13 09:08:45 +02:00
Ukpono Nnah
49f547585e
tutorial.md: Fix let bindings (#75)
Fix let bindings uneven form
2024-04-13 09:06:01 +02:00
Eddú Meléndez
874d5756af
Update branch to main 2023-08-24 15:57:19 -06:00
Eddú Meléndez Gonzales
9bf75d6387
Add release workflow (#70) 2023-08-24 14:47:48 -06:00
Tim Zöller
8c807a8750
Update testcontainers version to 1.19.0 (#69) 2023-08-23 18:10:26 -06:00
Tim Zöller
390563ac1d Updated project dependencies (#67) 2022-11-16 22:56:32 +01:00
Tim Zöller
667a2d0850 Refactored cleanup to not use deprecated methods anymore (#66) 2022-11-16 22:50:44 +01:00
Tim Zöller
94e582a1aa Upgraded to latest testcontainers-java version (#65) 2022-11-16 15:10:17 +01:00
Brendon Wong
100a938250
The parameter for copy-file-to-container! is container-path not host-path. (#64) 2022-10-06 11:44:46 +02:00
Tim Zöller
25d1ba491b Prepare Release 0.7.3 2022-09-30 12:30:57 +02:00
Tim Zöller
35454d3fd2 Upgrade to testcontainers-java 1.17.4 (#63) 2022-09-30 12:23:59 +02:00
Tim Zöller
1bf2c205c1 Applied automatic styling 2022-07-03 17:22:00 +02:00
Tim Zöller
5464fc35fa Bumped to testcontainers-java 1.17.3 2022-07-03 17:20:21 +02:00
Tim Zöller
d9a42decb2 Fixed deps.edn versios 2022-06-12 14:00:15 +02:00
Tim Zöller
dd517094ce Fixed changelog, set release version 2022-06-12 11:33:45 +02:00
Tim Zöller
fffb398918 Use nginx Docker image for HTTP wait status test 2022-06-12 11:30:56 +02:00
Tim Zöller
e57261ce12 Added allow-insecure flag (#58) 2022-05-25 09:08:32 +02:00
Tim Zöller
ba77335753 Dependency update to Testcontainers 1.17.2 (#57) 2022-05-25 09:00:21 +02:00
12 changed files with 299 additions and 188 deletions

18
.github/actions/setup-build/action.yml vendored Normal file
View file

@ -0,0 +1,18 @@
name: Set up Build
description: Sets up Build
runs:
using: "composite"
steps:
- uses: actions/setup-java@v4
with:
java-version: '8'
distribution: temurin
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-lein-${{ hashFiles('**/project.clj') }}
restore-keys: ${{ runner.os }}-lein-
- name: Clear existing docker image cache
shell: bash
run: docker image prune -af

View file

@ -2,17 +2,20 @@ name: Clojure CI
on: on:
push: push:
branches: [ master ] branches: [ main ]
pull_request: pull_request:
branches: [ master ] branches: [ main ]
permissions:
contents: read
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v4
- name: Setup Build
uses: ./.github/actions/setup-build
- name: Install dependencies - name: Install dependencies
run: lein deps run: lein deps
- name: Run tests - name: Run tests

28
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,28 @@
name: Release
on:
release:
types: [published]
permissions:
contents: read
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Build
uses: ./.github/actions/setup-build
- name: Set version
run: |
lein change version set '"${{github.event.release.tag_name}}"'
- name: Release ${{github.event.release.tag_name}}
run: lein with-profile release deploy maven
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

View file

@ -1,6 +1,32 @@
# Change Log # 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/). All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
## [0.7.4] - 2022-11-16
### Changed
- [#64](https://github.com/javahippie/clj-test-containers/pull/64): Fix container path parameter for copy-file-to-container! in README
- [#65](https://github.com/javahippie/clj-test-containers/issues/65): Upgrade to testcontainers-java 1.17.6
- [#66](https://github.com/javahippie/clj-test-containers/issues/66): Remove usage of deprecated API calls for cleanup
- [#67](https://github.com/javahippie/clj-test-containers/issues/67): Update Dependencies
## [0.7.3] - 2202-09-30
### Changed
- [#63](https://github.com/javahippie/clj-test-containers/issues/63): Upgrade to testcontainers-java 1.17.4
## [0.7.2] - 2202-07-03
### Changed
- [#61](https://github.com/javahippie/clj-test-containers/issues/61): Upgrade to testcontainers-java 1.17.3
## [0.7.1] - 2202-06-12
### Added
- [#58](https://github.com/javahippie/clj-test-containers/issues/58): Add new `allowInsecure` flag to the HTTP wait strategy
### Changed
- [#57](https://github.com/javahippie/clj-test-containers/issues/57): Upgrade to testcontainers-java 1.17.2
## [0.7.0] - 2022-04-23
### Changed
- [#56](https://github.com/javahippie/clj-test-containers/issues/56): Update to Testcontainers 1.17.1
## [0.6.0] - 2022-03-26 ## [0.6.0] - 2022-03-26
### Changed ### Changed
- [#55](https://github.com/javahippie/clj-test-containers/issues/55): Upgrade to latest Testcontainers version - [#55](https://github.com/javahippie/clj-test-containers/issues/55): Upgrade to latest Testcontainers version

View file

@ -346,7 +346,7 @@ Copies a file from your filesystem or classpath into the running container
| `container-config`| Map, mandatory | Return value of the `create` function | | `container-config`| Map, mandatory | Return value of the `create` function |
| Second parameter: | | | | Second parameter: | | |
| `:path` | String, mandatory | Path to a classpath resource *or* file on your filesystem | | `:path` | String, mandatory | Path to a classpath resource *or* file on your filesystem |
| `:host-path` | String, mandatory | Path, to which the file should be copied | | `:container-path` | String, mandatory | Path, to which the file should be copied |
| `:type` | Keyword, mandatory | `:classpath-resource` or `:host-path` | | `:type` | Keyword, mandatory | `:classpath-resource` or `:host-path` |
#### Result: #### Result:

View file

@ -1,27 +1,27 @@
{:paths ["src" "resources"] {:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.3"} :deps {org.clojure/clojure {:mvn/version "1.10.3"}
org.testcontainers/testcontainers {:mvn/version "1.16.3"}} org.testcontainers/testcontainers {:mvn/version "1.19.7"}}
:aliases {:dev {:extra-paths "dev-src"} :aliases {:dev {:extra-paths "dev-src"}
:test {:extra-paths ["test" "test/resources"] :test {:extra-paths ["test" "test/resources"]
:extra-deps {expound/expound {:mvn/version "0.9.0"} :extra-deps {expound/expound {:mvn/version "0.9.0"}
lambdaisland/kaocha {:mvn/version "1.63.998"} lambdaisland/kaocha {:mvn/version "1.88.1376"}
lambdaisland/kaocha-cloverage {:mvn/version "1.0.75"} lambdaisland/kaocha-cloverage {:mvn/version "1.1.89"}
lambdaisland/kaocha-junit-xml {:mvn/version "0.0.76"} lambdaisland/kaocha-junit-xml {:mvn/version "1.17.101"}
org.clojure/test.check {:mvn/version "1.1.1"} org.clojure/test.check {:mvn/version "1.1.1"}
org.testcontainers/postgresql {:mvn/version "1.16.3"}}} org.testcontainers/postgresql {:mvn/version "1.19.7"}}}
:test-runner {:extra-paths ["test" "test/resources"] :test-runner {:extra-paths ["test" "test/resources"]
:extra-deps {expound/expound {:mvn/version "0.8.5"} :extra-deps {expound/expound {:mvn/version "0.9.0"}
lambdaisland/kaocha {:mvn/version "1.0.700"} lambdaisland/kaocha {:mvn/version "1.88.1376"}
lambdaisland/kaocha-cloverage {:mvn/version "1.0.63"} lambdaisland/kaocha-cloverage {:mvn/version "1.1.89"}
lambdaisland/kaocha-junit-xml {:mvn/version "0.0.76"} lambdaisland/kaocha-junit-xml {:mvn/version "1.17.101"}
org.clojure/test.check {:mvn/version "1.1.1"} org.clojure/test.check {:mvn/version "1.1.1"}
orchestra {:mvn/version "2021.01.01-1"} orchestra {:mvn/version "2021.01.01-1"}
org.testcontainers/postgresql {:mvn/version "1.16.3"}} org.testcontainers/postgresql {:mvn/version "1.19.7"}}
:main-opts ["-m" "kaocha.runner" "--reporter" "kaocha.report/documentation"]} :main-opts ["-m" "kaocha.runner" "--reporter" "kaocha.report/documentation"]}
:cljstyle {:extra-deps {mvxcvi/cljstyle {:mvn/version "0.15.0" :cljstyle {:extra-deps {mvxcvi/cljstyle {:mvn/version "0.16.630"
:exclusions [org.clojure/clojure]}} :exclusions [org.clojure/clojure]}}
:main-opts ["-m" "cljstyle.main" "check"]}}} :main-opts ["-m" "cljstyle.main" "check"]}}}

View file

@ -4,13 +4,13 @@ This library offers two ways to access the logs of the running container: The :s
## String Strategy ## String Strategy
The `:string` strategy sets up a function in the returned map, under the `string-log` key. This function enables the The `:string` strategy sets up a function in the returned map, under the `:log` key. This function enables the
dumping of the logs when passed to the `dump-logs` function. dumping of the logs when passed to the `dump-logs` function.
Example: Example:
```clojure ```clojure
{:log-strategy :string} {:log-to {:log-strategy :string}}
``` ```
Then, later in your program, you can access the logs thus: Then, later in your program, you can access the logs thus:
@ -29,6 +29,6 @@ This way you can pass the container logging on to the logging library of your ch
Example: Example:
```clojure ```clojure
{:log-strategy :fn {:log-to {:log-strategy :fn
:function (fn [log-line] (println "From Container: " log-line)} :function (fn [log-line] (println "From Container: " log-line))}}
``` ```

View file

@ -89,10 +89,10 @@ atom, a fixture for Testcontainers could look like this:
```clojure ```clojure
(use-fixtures :once (fn [f] (use-fixtures :once (fn [f]
(let [{pw "apassword" (let [pw "apassword"
postgres (tc/start! (tc/create {:image-name "postgres:12.2" postgres (tc/start! (tc/create {:image-name "postgres:12.2"
:exposed-ports [5432] :exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" pw}}))}] :env-vars {"POSTGRES_PASSWORD" pw}}))]
(my-app/initialize-db! {:dbtype "postgresql" (my-app/initialize-db! {:dbtype "postgresql"
:dbname "postgres" :dbname "postgres"
:user "postgres" :user "postgres"

View file

@ -18,6 +18,7 @@ criteria is met.
| method | String | The HTTP method to use (get, post, put...) | | method | String | The HTTP method to use (get, post, put...) |
| status-codes | seq of int | The status codes which mark a successful request | | status-codes | seq of int | The status codes which mark a successful request |
| tls | boolean | Should TLS be used? | | tls | boolean | Should TLS be used? |
| allow-insecure | boolean | Should insecure HTTP endpoints be trusted? |
| read-timeout | long | The duration in seconds the HTTP may take | | read-timeout | long | The duration in seconds the HTTP may take |
| basic-credentials | Map | {:username "User" :password "Password"} | | basic-credentials | Map | {:username "User" :password "Password"} |
| headers | Map | HTTP Headers, e.g. {"Accept" "application/json"} | | headers | Map | HTTP Headers, e.g. {"Accept" "application/json"} |

View file

@ -1,13 +1,13 @@
(defproject clj-test-containers "0.7.0" (defproject testcontainers-clj "unspecified"
:description "A lightweight, unofficial wrapper around the Testcontainers Java library" :description "A lightweight, official wrapper around the Testcontainers Java library"
:url "https://github.com/javahippie/clj-test-containers" :url "https://github.com/testcontainers/testcontainers-clj"
:license {:name "Eclipse Public License" :license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"} :url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.10.3"] :dependencies [[org.clojure/clojure "1.10.3"]
[org.testcontainers/testcontainers "1.17.1"]] [org.testcontainers/testcontainers "1.19.7"]]
:aliases {"test" ["run" "-m" "kaocha.runner"] :aliases {"test" ["run" "-m" "kaocha.runner"]
"cljstyle" ["run" "-m" "cljstyle.main"]} "cljstyle" ["run" "-m" "cljstyle.main"]}
@ -15,16 +15,20 @@
:plugins [[jainsahab/lein-githooks "1.0.0"]] :plugins [[jainsahab/lein-githooks "1.0.0"]]
:profiles {:dev {:dependencies [[expound "0.9.0"] :profiles {:dev {:dependencies [[expound "0.9.0"]
[lambdaisland/kaocha "1.65.1029"] [lambdaisland/kaocha "1.88.1376"]
[lambdaisland/kaocha-cloverage "1.0.75"] [lambdaisland/kaocha-cloverage "1.1.89"]
[lambdaisland/kaocha-junit-xml "0.0.76"] [lambdaisland/kaocha-junit-xml "1.17.101"]
[mvxcvi/cljstyle "0.15.0" :exclusions [org.clojure/clojure]] [mvxcvi/cljstyle "0.16.630" :exclusions [org.clojure/clojure]]
[org.clojure/test.check "1.1.1"] [org.clojure/test.check "1.1.1"]
[orchestra "2021.01.01-1"] [orchestra "2021.01.01-1"]
[org.clojure/tools.namespace "1.2.0"] [org.clojure/tools.namespace "1.5.0"]
[org.testcontainers/postgresql "1.16.3"] [org.testcontainers/postgresql "1.19.7"]
[com.fzakaria/slf4j-timbre "0.3.21"] [com.fzakaria/slf4j-timbre "0.4.1"]
[nrepl "0.9.0"]] [nrepl "1.0.0"]]
:source-paths ["dev-src"]}} :source-paths ["dev-src"]}
:release {:deploy-repositories [["maven" {:url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
:username :env/ossrh_username
:password :env/ossrh_password
:sign-releases false}]]}}
:target-path "target/%s") :target-path "target/%s")

View file

@ -8,6 +8,7 @@
Paths) Paths)
(java.time (java.time
Duration) Duration)
(org.testcontainers DockerClientFactory)
(org.testcontainers.containers (org.testcontainers.containers
BindMode BindMode
GenericContainer GenericContainer
@ -21,8 +22,7 @@
(org.testcontainers.images.builder (org.testcontainers.images.builder
ImageFromDockerfile) ImageFromDockerfile)
(org.testcontainers.utility (org.testcontainers.utility
MountableFile MountableFile)))
ResourceReaper)))
(defn- resolve-bind-mode (defn- resolve-bind-mode
(^BindMode [bind-mode] (^BindMode [bind-mode]
@ -30,9 +30,7 @@
BindMode/READ_WRITE BindMode/READ_WRITE
BindMode/READ_ONLY))) BindMode/READ_ONLY)))
(defn- reaper-instance (defonce started-instances (atom #{}))
[]
(ResourceReaper/instance))
(defmulti wait (defmulti wait
"Sets a wait strategy to the container. Supports :http, :health and :log as "Sets a wait strategy to the container. Supports :http, :health and :log as
@ -102,6 +100,7 @@
method method
status-codes status-codes
tls tls
allow-insecure
read-timeout read-timeout
basic-credentials basic-credentials
headers headers
@ -120,6 +119,9 @@
(when tls (when tls
(.usingTls for-http)) (.usingTls for-http))
(when allow-insecure
(.allowInsecure for-http))
(when read-timeout (when read-timeout
(.withReadTimeout for-http (Duration/ofSeconds read-timeout))) (.withReadTimeout for-http (Duration/ofSeconds read-timeout)))
@ -332,7 +334,10 @@
(defn dump-logs (defn dump-logs
"Dumps the logs found by invoking the function on the :string-log key" "Dumps the logs found by invoking the function on the :string-log key"
[container-config] [container-config]
((:log container-config))) (let [log-fn (:log container-config)]
(if (some? log-fn)
(log-fn)
(throw (IllegalStateException. "You are trying to access the container logs, but have not configured a log configuration with :log-to")))))
(defn start! (defn start!
"Starts the underlying testcontainer instance and adds new values to the "Starts the underlying testcontainer instance and adds new values to the
@ -348,9 +353,7 @@
container-id ^String (.getContainerId container) container-id ^String (.getContainerId container)
image-name ^String (.getDockerImageName container) image-name ^String (.getDockerImageName container)
logger (log log-to container)] logger (log log-to container)]
(.registerContainerForCleanup ^ResourceReaper (reaper-instance) (swap! started-instances conj {:type :container :id container-id})
container-id
image-name)
(-> container-config (-> container-config
(merge {:id container-id (merge {:id container-id
:mapped-ports mapped-ports :mapped-ports mapped-ports
@ -384,7 +387,7 @@
(let [network (.build builder) (let [network (.build builder)
network-name (.getName network)] network-name (.getName network)]
(.registerNetworkIdForCleanup ^ResourceReaper (reaper-instance) network-name) (swap! started-instances conj {:type :network :id :network-name})
{:network network {:network network
:name network-name :name network-name
:ipv6 (.getEnableIpv6 network) :ipv6 (.getEnableIpv6 network)
@ -392,10 +395,32 @@
(def ^:deprecated init-network create-network) (def ^:deprecated init-network create-network)
(defn- remove-network! [instance]
(-> (DockerClientFactory/instance)
(.client)
(.removeNetworkCmd (:id instance))
(.exec))
instance)
(defn- stop-and-remove-container! [instance]
(let [docker-client (DockerClientFactory/instance)]
(-> docker-client
(.client)
(.stopContainerCmd (:id instance))
(.exec))
(-> docker-client
(.client)
(.removeContainerCmd (:id instance))
(.exec)))
instance)
(defn perform-cleanup! (defn perform-cleanup!
"Stops and removes all container instances which were created in the active JVM or REPL session" "Stops and removes all container instances which were created in the active JVM or REPL session"
[] []
(.performCleanup ^ResourceReaper (reaper-instance))) (for [instance @started-instances]
(swap! started-instances disj (case (:type instance)
:container (stop-and-remove-container! instance)
:network (remove-network! instance)))))
;; REPL Helpers ;; REPL Helpers

View file

@ -9,7 +9,7 @@
(deftest create-test (deftest create-test
(testing "Testing basic testcontainer generic image initialisation" (testing "Testing basic testcontainer generic image initialisation"
(let [container (sut/create {:image-name "postgres:12.2" (let [container (sut/create {:image-name "postgres:15.3"
:exposed-ports [5432] :exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" "pw"}}) :env-vars {"POSTGRES_PASSWORD" "pw"}})
initialized-container (sut/start! container) initialized-container (sut/start! container)
@ -21,7 +21,9 @@
(is (nil? (:mapped-ports stopped-container))))) (is (nil? (:mapped-ports stopped-container)))))
(testing "Testing log access to the container with string logs" (testing "Testing log access to the container with string logs"
(let [container (sut/init {:container (PostgreSQLContainer. "postgres:12.2") (let [container (sut/create {:image-name "postgres:15.3"
:exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" "pw"}
:log-to {:log-strategy :string}}) :log-to {:log-strategy :string}})
initialized-container (sut/start! container)] initialized-container (sut/start! container)]
(Thread/sleep 500) (Thread/sleep 500)
@ -29,13 +31,19 @@
(testing "Testing log access to the container with function logs" (testing "Testing log access to the container with function logs"
(let [logs (atom [])] (let [logs (atom [])]
(sut/start! (sut/init {:container (PostgreSQLContainer. "postgres:12.2") (sut/start! (sut/init {:container (PostgreSQLContainer. "postgres:15.3")
:exposed-ports [5432]
:log-to {:log-strategy :fn :log-to {:log-strategy :fn
:function #(swap! logs conj %)}})) :function #(swap! logs conj %)}}))
(is (filter #(includes? "database system is ready to accept connections" %) @logs)))) (is (filter #(includes? "database system is ready to accept connections" %) @logs))))
(testing "Testing log access to the container with unconfigured logger"
(let [container (sut/start! (sut/init {:container (PostgreSQLContainer. "postgres:15.3")
:exposed-ports [5432]}))]
(is (thrown? IllegalStateException (sut/dump-logs container)))))
(testing "Testing basic testcontainer generic image initialisation with wait for log message" (testing "Testing basic testcontainer generic image initialisation with wait for log message"
(let [container (sut/create {:image-name "postgres:12.2" (let [container (sut/create {:image-name "postgres:15.3"
:exposed-ports [5432] :exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" "pw"} :env-vars {"POSTGRES_PASSWORD" "pw"}
:wait-for {:wait-strategy :log :wait-for {:wait-strategy :log
@ -51,7 +59,7 @@
(is (nil? (:mapped-ports stopped-container))))) (is (nil? (:mapped-ports stopped-container)))))
(testing "Testing basic testcontainer generic image initialisation with wait for host port" (testing "Testing basic testcontainer generic image initialisation with wait for host port"
(let [container (sut/create {:image-name "postgres:12.2" (let [container (sut/create {:image-name "postgres:15.3"
:exposed-ports [5432] :exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" "pw"} :env-vars {"POSTGRES_PASSWORD" "pw"}
:wait-for {:wait-strategy :port}}) :wait-for {:wait-strategy :port}})
@ -65,11 +73,8 @@
(is (nil? (:mapped-ports stopped-container))))) (is (nil? (:mapped-ports stopped-container)))))
(testing "Testing basic testcontainer generic image initialisation with wait for http" (testing "Testing basic testcontainer generic image initialisation with wait for http"
(let [container (sut/create {:image-name "alpine:3.5" (let [container (sut/create {:image-name "bitnami/nginx:1.22"
:network-aliases ["foo"] :network-aliases ["foo"]
:command ["/bin/sh"
"-c"
"while true ; do printf 'HTTP/1.1 200 OK\\n\\nyay' | nc -l -p 8080; done"]
:exposed-ports [8080] :exposed-ports [8080]
:wait-for {:wait-strategy :http :wait-for {:wait-strategy :http
:path "/" :path "/"
@ -104,7 +109,8 @@
(testing "Executing a command in the running Docker container with a custom container" (testing "Executing a command in the running Docker container with a custom container"
(let [container (sut/init {:container (PostgreSQLContainer. "postgres:12.2")}) (let [container (sut/init {:container (PostgreSQLContainer. "postgres:15.3")
:exposed-ports [5432]})
initialized-container (sut/start! container) initialized-container (sut/start! container)
result (sut/execute-command! initialized-container ["whoami"]) result (sut/execute-command! initialized-container ["whoami"])
_stopped-container (sut/stop! container)] _stopped-container (sut/stop! container)]
@ -114,7 +120,7 @@
(deftest execute-command-in-container (deftest execute-command-in-container
(testing "Executing a command in the running Docker container" (testing "Executing a command in the running Docker container"
(let [container (sut/create {:image-name "postgres:12.2" (let [container (sut/create {:image-name "postgres:15.3"
:exposed-ports [5432] :exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" "pw"}}) :env-vars {"POSTGRES_PASSWORD" "pw"}})
initialized-container (sut/start! container) initialized-container (sut/start! container)
@ -126,7 +132,7 @@
(deftest init-volume-test (deftest init-volume-test
(testing "Testing mapping of a classpath resource" (testing "Testing mapping of a classpath resource"
(let [container (-> (sut/create {:image-name "postgres:12.2" (let [container (-> (sut/create {:image-name "postgres:15.3"
:exposed-ports [5432] :exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" "pw"}}) :env-vars {"POSTGRES_PASSWORD" "pw"}})
(sut/map-classpath-resource! {:resource-path "test.sql" (sut/map-classpath-resource! {:resource-path "test.sql"
@ -143,7 +149,7 @@
(is (nil? (:mapped-ports stopped-container))))) (is (nil? (:mapped-ports stopped-container)))))
(testing "Testing mapping of a filesystem-binding" (testing "Testing mapping of a filesystem-binding"
(let [container (-> (sut/create {:image-name "postgres:12.2" (let [container (-> (sut/create {:image-name "postgres:15.3"
:exposed-ports [5432] :exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" "pw"}}) :env-vars {"POSTGRES_PASSWORD" "pw"}})
(sut/bind-filesystem! {:host-path "." (sut/bind-filesystem! {:host-path "."
@ -160,7 +166,7 @@
(is (nil? (:mapped-ports stopped-container))))) (is (nil? (:mapped-ports stopped-container)))))
(testing "Copying a file from the host into the container" (testing "Copying a file from the host into the container"
(let [container (-> (sut/create {:image-name "postgres:12.2" (let [container (-> (sut/create {:image-name "postgres:15.3"
:exposed-ports [5432] :exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" "pw"}}) :env-vars {"POSTGRES_PASSWORD" "pw"}})
(sut/copy-file-to-container! {:path "test.sql" (sut/copy-file-to-container! {:path "test.sql"
@ -178,7 +184,7 @@
(testing "Copying a file from the classpath into the container" (testing "Copying a file from the classpath into the container"
(let [container (-> (sut/create {:image-name "postgres:12.2" (let [container (-> (sut/create {:image-name "postgres:15.3"
:exposed-ports [5432] :exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" "pw"}}) :env-vars {"POSTGRES_PASSWORD" "pw"}})
(sut/copy-file-to-container! {:path "test.sql" (sut/copy-file-to-container! {:path "test.sql"
@ -195,7 +201,7 @@
(is (nil? (:mapped-ports stopped-container))))) (is (nil? (:mapped-ports stopped-container)))))
(testing "Copying a file from the host into a running container" (testing "Copying a file from the host into a running container"
(let [container (sut/create {:image-name "postgres:12.2" (let [container (sut/create {:image-name "postgres:15.3"
:exposed-ports [5432] :exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" "pw"}}) :env-vars {"POSTGRES_PASSWORD" "pw"}})
initialized-container (sut/start! container) initialized-container (sut/start! container)
@ -214,7 +220,7 @@
(is (nil? (:mapped-ports stopped-container))))) (is (nil? (:mapped-ports stopped-container)))))
(testing "Copying a file from the classpath into a running container" (testing "Copying a file from the classpath into a running container"
(let [container (sut/create {:image-name "postgres:12.2" (let [container (sut/create {:image-name "postgres:15.3"
:exposed-ports [5432] :exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" "pw"}}) :env-vars {"POSTGRES_PASSWORD" "pw"}})
initialized-container (sut/start! container) initialized-container (sut/start! container)