Skip to content

Commit

Permalink
add is_starting callback in builder (experimental)
Browse files Browse the repository at this point in the history
jarlah committed Nov 29, 2023
1 parent 5d478d3 commit 05bab97
Showing 10 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/container.ex
Original file line number Diff line number Diff line change
@@ -146,5 +146,9 @@ defmodule Testcontainers.Container do
def build(%Testcontainers.Container{} = config) do
config
end

@impl true
@spec is_starting(%Testcontainers.Container{}, %Testcontainers.Container{}) :: any()
def is_starting(_config, _container), do: nil
end
end
4 changes: 4 additions & 0 deletions lib/container/cassandra_container.ex
Original file line number Diff line number Diff line change
@@ -80,5 +80,9 @@ defmodule Testcontainers.CassandraContainer do
)
)
end

@impl true
@spec is_starting(%CassandraContainer{}, %Container{}) :: any()
def is_starting(_config, _container), do: nil
end
end
4 changes: 4 additions & 0 deletions lib/container/ceph_container.ex
Original file line number Diff line number Diff line change
@@ -230,6 +230,10 @@ defmodule Testcontainers.CephContainer do
)
)
end

@impl true
@spec is_starting(%CephContainer{}, %Container{}) :: any()
def is_starting(_config, _container), do: nil
end
end

4 changes: 4 additions & 0 deletions lib/container/minio_container.ex
Original file line number Diff line number Diff line change
@@ -74,5 +74,9 @@ defmodule Testcontainers.MinioContainer do
LogWaitStrategy.new(~r/.*Status: 1 Online, 0 Offline..*/, config.wait_timeout)
)
end

@impl true
@spec is_starting(%MinioContainer{}, %Container{}) :: any()
def is_starting(_config, _container), do: nil
end
end
4 changes: 4 additions & 0 deletions lib/container/mysql_container.ex
Original file line number Diff line number Diff line change
@@ -205,6 +205,10 @@ defmodule Testcontainers.MySqlContainer do
LogWaitStrategy.new(~r/.*port: 3306 MySQL Community Server.*/, config.wait_timeout)
)
end

@impl true
@spec is_starting(%MySqlContainer{}, %Container{}) :: any()
def is_starting(_config, _container), do: nil
end

@doc false
4 changes: 4 additions & 0 deletions lib/container/postgres_container.ex
Original file line number Diff line number Diff line change
@@ -211,6 +211,10 @@ defmodule Testcontainers.PostgresContainer do
)
)
end

@impl true
@spec is_starting(%PostgresContainer{}, %Container{}) :: any()
def is_starting(_config, _container), do: nil
end

@doc false
3 changes: 3 additions & 0 deletions lib/container/protocols/container_builder.ex
Original file line number Diff line number Diff line change
@@ -4,4 +4,7 @@ defprotocol Testcontainers.ContainerBuilder do
"""
@spec build(t()) :: %Testcontainers.Container{}
def build(builder)

@spec is_starting(t(), %Testcontainers.Container{}) :: any()
def is_starting(builder, container)
end
4 changes: 4 additions & 0 deletions lib/container/redis_container.ex
Original file line number Diff line number Diff line change
@@ -139,6 +139,10 @@ defmodule Testcontainers.RedisContainer do
CommandWaitStrategy.new(["redis-cli", "PING"], config.wait_timeout)
)
end

@impl true
@spec is_starting(%RedisContainer{}, %Container{}) :: any()
def is_starting(_config, _container), do: nil
end
end

4 changes: 4 additions & 0 deletions lib/container/selenium_container.ex
Original file line number Diff line number Diff line change
@@ -68,6 +68,10 @@ defmodule Testcontainers.SeleniumContainer do
PortWaitStrategy.new("127.0.0.1", config.port2, config.wait_timeout, 1000)
])
end

@impl true
@spec is_starting(%SeleniumContainer{}, %Container{}) :: any()
def is_starting(_config, _container), do: nil
end
end

1 change: 1 addition & 0 deletions lib/testcontainers.ex
Original file line number Diff line number Diff line change
@@ -215,6 +215,7 @@ defmodule Testcontainers do
{:ok, id} <- Api.create_container(config, state.conn),
:ok <- Api.start_container(id, state.conn),
{:ok, container} <- Api.get_container(id, state.conn),
_ <- ContainerBuilder.is_starting(config, container),
:ok <- wait_for_container(container, config.wait_strategies || [], state.conn) do
{:ok, container}
end

0 comments on commit 05bab97

Please sign in to comment.