#1 - Streamlined API some more
This commit is contained in:
parent
a6d6c10fde
commit
9991a153dd
3 changed files with 20 additions and 10 deletions
10
README.md
10
README.md
|
|
@ -8,9 +8,17 @@ This library does not provide tools to include testcontainers in your testing li
|
|||
|
||||
|
||||
## 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
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
(defn create
|
||||
"Sets the properties for a testcontainer instance"
|
||||
[{image-name :image-name
|
||||
|
||||
exposed-ports :exposed-ports
|
||||
env-vars :env-vars
|
||||
command :command}]
|
||||
|
|
@ -35,5 +34,8 @@
|
|||
|
||||
(defn stop
|
||||
"Stops the underlying container"
|
||||
[{container :container}]
|
||||
(.stop container))
|
||||
[container-conf]
|
||||
(.stop (:container container-conf))
|
||||
(-> container-conf
|
||||
(dissoc :id)
|
||||
(dissoc :mapped-ports)))
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@
|
|||
:exposed-ports [5432]
|
||||
:env-vars {"POSTGRES_PASSWORD" "pw"}})
|
||||
initialized-container (start container)
|
||||
container-id (:id initialized-container)
|
||||
mapped-ports (:mapped-ports initialized-container)]
|
||||
(is (some? container-id))
|
||||
(is (some? mapped-ports))
|
||||
(is (some? (get mapped-ports 5432)))
|
||||
(stop container))))
|
||||
stopped-container (stop container)]
|
||||
(is (some? (:id initialized-container)))
|
||||
(is (some? (:mapped-ports initialized-container)))
|
||||
(is (some? (get (:mapped-ports initialized-container) 5432)))
|
||||
(is (nil? (:id stopped-container)))
|
||||
(is (nil? (:mapped-ports stopped-container))))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue