Current section

72 Versions

Jump to

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