Packages
testcontainers
1.1.2
2.3.1
2.3.0
2.2.0
2.1.0
2.1.0-rc1
2.0.0
2.0.0-rc3
2.0.0-rc2
2.0.0-rc
1.14.1
1.14.0
1.13.5
1.13.4
1.13.3
1.13.2
1.13.1
1.13.0
1.12.0
1.11.8
1.11.7
1.11.6
1.11.5
1.11.4
1.11.3
1.11.2
1.11.1
1.11.0
1.10.5
1.10.4
1.10.3
1.10.2
1.10.1
1.10.0
1.9.0
1.8.4
1.8.3
1.8.2
1.8.1
1.8.0
1.7.0
1.6.0
1.5.1
1.5.0
1.4.2
1.4.1
1.4.0
1.3.1
1.3.0
1.2.11
1.2.10
1.2.9
1.2.8
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.3
1.1.2
1.1.1
1.1.0
1.0.1
1.0.0
1.0.0-beta.1
1.0.0-beta
0.9.3
0.9.2
0.9.1
0.9.0
Testcontainers is an Elixir library that supports ExUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
Current section
72 Versions
Jump to
Current section
72 Versions
Compare versions
5
files changed
+17
additions
-10
deletions
| @@ -57,7 +57,11 @@ In simple terms you can add this in application.ex: | |
| 57 57 | end |
| 58 58 | ``` |
| 59 59 | |
| 60 | - see documentation on Testcontainers.Ecto for more information. |
| 60 | + see documentation on Testcontainers.Ecto for more information about the options it can take. |
| 61 | + |
| 62 | + There is an example repo here with a bare bones phoenix application, where the only changes are the inclusion of the ecto macro and removing the test alias that interferes with the macro: |
| 63 | + |
| 64 | + [https://github.com/jarlah/hello_testcontainers](https://github.com/jarlah/hello_testcontainers) |
| 61 65 | |
| 62 66 | ### Simple example |
| @@ -1,7 +1,7 @@ | |
| 1 1 | {<<"links">>, |
| 2 2 | [{<<"GitHub">>,<<"https://github.com/jarlah/testcontainers-elixir">>}]}. |
| 3 3 | {<<"name">>,<<"testcontainers">>}. |
| 4 | - {<<"version">>,<<"1.1.1">>}. |
| 4 | + {<<"version">>,<<"1.1.2">>}. |
| 5 5 | {<<"description">>, |
| 6 6 | <<"Testcontainers is an Elixir library that supports ExUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.">>}. |
| 7 7 | {<<"elixir">>,<<"~> 1.15">>}. |
| @@ -63,12 +63,14 @@ defmodule Testcontainers.Container do | |
| 63 63 | Adds a _port_ to be exposed on the _container_. |
| 64 64 | """ |
| 65 65 | def with_exposed_port(%__MODULE__{} = config, port) when is_integer(port) do |
| 66 | - %__MODULE__{config | exposed_ports: [port | config.exposed_ports]} |
| 66 | + filtered_ports = config.exposed_ports |> Enum.reject(fn p -> p == port end) |
| 67 | + |
| 68 | + %__MODULE__{config | exposed_ports: [port | filtered_ports]} |
| 67 69 | end |
| 68 70 | |
| 69 71 | def with_fixed_port(%__MODULE__{} = config, port, host_port \\ nil) |
| 70 72 | when is_integer(port) and (is_nil(host_port) or is_integer(host_port)) do |
| 71 | - filtered_ports = config.exposed_ports |> Enum.filter(fn port -> port != port end) |
| 73 | + filtered_ports = config.exposed_ports |> Enum.reject(fn p -> p == port end) |
| 72 74 | |
| 73 75 | %__MODULE__{ |
| 74 76 | config |
| @@ -82,7 +84,9 @@ defmodule Testcontainers.Container do | |
| 82 84 | Adds multiple _ports_ to be exposed on the _container_. |
| 83 85 | """ |
| 84 86 | def with_exposed_ports(%__MODULE__{} = config, ports) when is_list(ports) do |
| 85 | - %__MODULE__{config | exposed_ports: ports ++ config.exposed_ports} |
| 87 | + filtered_ports = config.exposed_ports |> Enum.reject(fn port -> port in ports end) |
| 88 | + |
| 89 | + %__MODULE__{config | exposed_ports: ports ++ filtered_ports} |
| 86 90 | end |
| 87 91 | |
| 88 92 | @doc """ |
| @@ -95,17 +95,16 @@ defmodule Testcontainers.Ecto do | |
| 95 95 | |
| 96 96 | app = Keyword.get(options, :app) |
| 97 97 | |
| 98 | - if app == nil or not is_atom(app) or |
| 99 | - Application.ensure_loaded(app) != :ok do |
| 98 | + if app == nil or not is_atom(app) do |
| 100 99 | raise ArgumentError, |
| 101 | - "Missing or ot an application: #{inspect(app)}" |
| 100 | + "Missing or not an atom: app=#{inspect(app)}" |
| 102 101 | end |
| 103 102 | |
| 104 103 | repo = Keyword.get(options, :repo) |
| 105 104 | |
| 106 105 | if repo != nil and not is_atom(repo) do |
| 107 106 | raise ArgumentError, |
| 108 | - "Not an atom: #{inspect(repo)}" |
| 107 | + "Not an atom: repo=#{inspect(repo)}" |
| 109 108 | end |
| 110 109 | |
| 111 110 | repo = |
| @@ -2,7 +2,7 @@ defmodule TestcontainersElixir.MixProject do | |
| 2 2 | use Mix.Project |
| 3 3 | |
| 4 4 | @app :testcontainers |
| 5 | - @version "1.1.1" |
| 5 | + @version "1.1.2" |
| 6 6 | @source_url "https://github.com/jarlah/testcontainers-elixir" |
| 7 7 | |
| 8 8 | def project do |