Merge 436501caf5 into 802f18af55
This commit is contained in:
commit
e055b96675
2 changed files with 31 additions and 0 deletions
19
README.md
19
README.md
|
|
@ -421,6 +421,25 @@ Creates a network. The optional map accepts config values for enabling ipv6 and
|
||||||
(create-network)
|
(create-network)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### with-network
|
||||||
|
|
||||||
|
Create and bind a network to *network* and run `test-fn`. The network is removed after the function executes.
|
||||||
|
|
||||||
|
#### Config parameters:
|
||||||
|
|
||||||
|
`with-network` takes an optional map of options, equivalent to `create-network`.
|
||||||
|
|
||||||
|
|
||||||
|
#### Example:
|
||||||
|
|
||||||
|
```clojure
|
||||||
|
;; Run tests within an ephemeral network
|
||||||
|
(use-fixtures :once (tc/with-network {:ipv6? true}))
|
||||||
|
|
||||||
|
(deftest test-network-loaded
|
||||||
|
(is (some? tc/*network*)))
|
||||||
|
```
|
||||||
|
|
||||||
### perform-cleanup!
|
### perform-cleanup!
|
||||||
|
|
||||||
Stops and removes all containers which were created in the JVM, including the REPL session you are in. This is helpful,
|
Stops and removes all containers which were created in the JVM, including the REPL session you are in. This is helpful,
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@
|
||||||
BindMode/READ_WRITE
|
BindMode/READ_WRITE
|
||||||
BindMode/READ_ONLY)))
|
BindMode/READ_ONLY)))
|
||||||
|
|
||||||
|
(def ^:dynamic *network* nil)
|
||||||
|
|
||||||
(defonce started-instances (atom #{}))
|
(defonce started-instances (atom #{}))
|
||||||
|
|
||||||
(defmulti wait
|
(defmulti wait
|
||||||
|
|
@ -402,6 +404,16 @@
|
||||||
(.exec))
|
(.exec))
|
||||||
instance)
|
instance)
|
||||||
|
|
||||||
|
(defn with-network
|
||||||
|
([] (with-network {}))
|
||||||
|
([network-options]
|
||||||
|
(fn [test-fn]
|
||||||
|
(binding [*network* (create-network network-options)]
|
||||||
|
(try
|
||||||
|
(test-fn)
|
||||||
|
(finally
|
||||||
|
(remove-network! *network*)))))))
|
||||||
|
|
||||||
(defn- stop-and-remove-container! [instance]
|
(defn- stop-and-remove-container! [instance]
|
||||||
(let [docker-client (DockerClientFactory/instance)]
|
(let [docker-client (DockerClientFactory/instance)]
|
||||||
(-> docker-client
|
(-> docker-client
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue