#1 - Streamlined API some more

This commit is contained in:
Tim Zöller 2020-06-04 13:04:30 +02:00
parent a6d6c10fde
commit 9991a153dd
3 changed files with 20 additions and 10 deletions

View file

@ -8,9 +8,17 @@ This library does not provide tools to include testcontainers in your testing li
## Usage ## Usage
```clojure
(require '[clj-test-containers.core :as tc])
FIXME, if there is an API at all (def container (tc/create {:image-name "postgres:12.1"
:exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" "verysecret"}}))
(tc/start postgres)
(tc/stop postgres)
```
## License ## License

View file

@ -3,7 +3,6 @@
(defn create (defn create
"Sets the properties for a testcontainer instance" "Sets the properties for a testcontainer instance"
[{image-name :image-name [{image-name :image-name
exposed-ports :exposed-ports exposed-ports :exposed-ports
env-vars :env-vars env-vars :env-vars
command :command}] command :command}]
@ -35,5 +34,8 @@
(defn stop (defn stop
"Stops the underlying container" "Stops the underlying container"
[{container :container}] [container-conf]
(.stop container)) (.stop (:container container-conf))
(-> container-conf
(dissoc :id)
(dissoc :mapped-ports)))

View file

@ -8,9 +8,9 @@
:exposed-ports [5432] :exposed-ports [5432]
:env-vars {"POSTGRES_PASSWORD" "pw"}}) :env-vars {"POSTGRES_PASSWORD" "pw"}})
initialized-container (start container) initialized-container (start container)
container-id (:id initialized-container) stopped-container (stop container)]
mapped-ports (:mapped-ports initialized-container)] (is (some? (:id initialized-container)))
(is (some? container-id)) (is (some? (:mapped-ports initialized-container)))
(is (some? mapped-ports)) (is (some? (get (:mapped-ports initialized-container) 5432)))
(is (some? (get mapped-ports 5432))) (is (nil? (:id stopped-container)))
(stop container)))) (is (nil? (:mapped-ports stopped-container))))))