diff --git a/README.md b/README.md index c7a53a7..6c6d34e 100644 --- a/README.md +++ b/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 diff --git a/src/clj_test_containers/core.clj b/src/clj_test_containers/core.clj index b28127a..7858ea2 100644 --- a/src/clj_test_containers/core.clj +++ b/src/clj_test_containers/core.clj @@ -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))) diff --git a/test/clj_test_containers/core_test.clj b/test/clj_test_containers/core_test.clj index 360d7b7..2ff3bd1 100644 --- a/test/clj_test_containers/core_test.clj +++ b/test/clj_test_containers/core_test.clj @@ -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))))))