From 99732b5765292447b65b7c2f2ad62e9ecef5c7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Z=C3=B6ller?= Date: Thu, 4 Jun 2020 10:58:10 +0200 Subject: [PATCH] Initialized Dependencies and readme --- README.md | 12 ++++++++--- build.boot | 13 ++++++------ src/clj_test_containers/core.clj | 36 ++++++++++++++++++++++++++++---- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3b726f5..c7a53a7 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,20 @@ # clj-test-containers -A Clojure library designed to ... well, that part is up to you. +## What it is +This application is supposed to be a lightweight wrapper around the Testcontainers Java library. + +## What it isn't +This library does not provide tools to include testcontainers in your testing lifecycle. As there are many different test tools with different approaches to testing in the clojure world, handling the lifecycle is up to you. + ## Usage -FIXME +FIXME, if there is an API at all + ## License -Copyright © 2020 FIXME +Copyright © 2020 Tim Zöller Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version. diff --git a/build.boot b/build.boot index 81f8fcd..323833e 100644 --- a/build.boot +++ b/build.boot @@ -3,15 +3,16 @@ (set-env! :resource-paths #{"resources" "src"} :source-paths #{"test"} - :dependencies '[[org.clojure/clojure "RELEASE"] - [adzerk/boot-test "RELEASE" :scope "test"]]) + :dependencies '[[org.clojure/clojure "1.10.1"] + [org.testcontainers/testcontainers "1.14.3"] + [metosin/bat-test "0.4.4" :scope "test"]]) (task-options! pom {:project project :version version - :description "FIXME: write description" - :url "http://example/FIXME" - :scm {:url "https://github.com/yourname/clj-test-containers"} + :description "A lightweight, unofficial wrapper around the Testcontainers Java library" + :url "https://github.com/javahippie/clj-test-containers" + :scm {:url "https://github.com/javahippie/clj-test-containers"} :license {"Eclipse Public License" "http://www.eclipse.org/legal/epl-v10.html"}}) @@ -20,4 +21,4 @@ [] (comp (pom) (jar) (install))) -(require '[adzerk.boot-test :refer [test]]) +(require '[metosin.bat-test :refer (bat-test)]) diff --git a/src/clj_test_containers/core.clj b/src/clj_test_containers/core.clj index 445529b..e7aa2e0 100644 --- a/src/clj_test_containers/core.clj +++ b/src/clj_test_containers/core.clj @@ -1,6 +1,34 @@ (ns clj-test-containers.core) -(defn foo - "I don't do a whole lot." - [x] - (println x "Hello, World!")) +(defn init + "Sets the properties for a testcontainer instance" + [{image-name :image-name + exposed-ports :exposed-ports + env-vars :env-vars + command :command + fs-bind :file-system-bind + waiting-for :waiting-for + copy-file :copy-file-to-container + extra-host :extra-host + network :network + network-aliases :network-aliases + network-mode :network-mode + image-pull-policy :image-pull-policy + classpath-resource-mapping :classpath-resource-mapping + startup-timeout :startup-timeout + privileged-mode :privileged-mode + startup-check-strategy :startup-check-strategy + working-directory :working-directory + follow-ouptut :follow-output + log-consumer :log-consumer}] + (let [container (-> (org.testcontainers.containers.GenericContainer. image-name) + (.withExposedPorts (into-array Integer (map int exposed-ports))) + (.withEnv env-vars) + (as-> container + (if (some? command) + (.withCommand command) + container)))] + {:container container + :exposed-ports (.getExposedPorts container) + :env-vars (.getEnvMap container) + :host (.getHost container)}))