Skip to content

Commit

Permalink
chore: add link in readme and do some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlah committed Oct 25, 2023
1 parent ab0de7f commit 9de0a23
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ In simple terms you can add this in application.ex:
end
```

see documentation on Testcontainers.Ecto for more information about the options it can take.
see documentation on [https://hexdocs.pm/testcontainers/Testcontainers.Ecto.html](Testcontainers.Ecto) for more information about the options it can take.

There is an example repo here with a bare bones phoenix application, where the only changes are the use of the ecto function and removing the test alias that interferes with it:

Expand Down
43 changes: 20 additions & 23 deletions lib/testcontainers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -296,39 +296,35 @@ defmodule Testcontainers do
end

@impl true
def handle_call({:pull_image, image}, from, %{conn: conn} = state) do
Task.async(fn -> GenServer.reply(from, Api.pull_image(image, conn)) end)
def handle_call({:pull_image, image}, from, state) do
Task.async(fn -> GenServer.reply(from, Api.pull_image(image, state.conn)) end)
{:noreply, state}
end

@impl true
def handle_call({:get_container, container_id}, from, %{conn: conn} = state) do
Task.async(fn -> GenServer.reply(from, Api.get_container(container_id, conn)) end)
def handle_call({:get_container, container_id}, from, state) do
Task.async(fn -> GenServer.reply(from, Api.get_container(container_id, state.conn)) end)
{:noreply, state}
end

@impl true
def handle_call({:start_container, container_id}, from, %{conn: conn} = state) do
Task.async(fn -> GenServer.reply(from, Api.start_container(container_id, conn)) end)
def handle_call({:start_container, container_id}, from, state) do
Task.async(fn -> GenServer.reply(from, Api.start_container(container_id, state.conn)) end)
{:noreply, state}
end

@impl true
def handle_call(
{:create_container, container},
from,
%{conn: conn, session_id: session_id} = state
) do
def handle_call({:create_container, container}, from, state) do
Task.async(fn ->
GenServer.reply(
from,
Api.create_container(
container
|> Container.with_label(container_sessionId_label(), session_id)
|> Container.with_label(container_sessionId_label(), state.session_id)
|> Container.with_label(container_version_label(), library_version())
|> Container.with_label(container_lang_label(), container_lang_value())
|> Container.with_label(container_label(), "#{true}"),
conn
state.conn
)
)
end)
Expand All @@ -337,32 +333,33 @@ defmodule Testcontainers do
end

@impl true
def handle_call({:stop_container, container_id}, from, %{conn: conn} = state) do
Task.async(fn -> GenServer.reply(from, Api.stop_container(container_id, conn)) end)
def handle_call({:stop_container, container_id}, from, state) do
Task.async(fn -> GenServer.reply(from, Api.stop_container(container_id, state.conn)) end)
{:noreply, state}
end

@impl true
def handle_call({:stdout_logs, container_id}, from, %{conn: conn} = state) do
Task.async(fn -> GenServer.reply(from, Api.stdout_logs(container_id, conn)) end)
def handle_call({:stdout_logs, container_id}, from, state) do
Task.async(fn -> GenServer.reply(from, Api.stdout_logs(container_id, state.conn)) end)
{:noreply, state}
end

@impl true
def handle_call({:exec_create, command, container_id}, from, %{conn: conn} = state) do
Task.async(fn -> GenServer.reply(from, Api.create_exec(container_id, command, conn)) end)
def handle_call({:exec_create, command, container_id}, from, state) do
Task.async(fn -> GenServer.reply(from, Api.create_exec(container_id, command, state.conn)) end)

{:noreply, state}
end

@impl true
def handle_call({:exec_start, exec_id}, from, %{conn: conn} = state) do
Task.async(fn -> GenServer.reply(from, Api.start_exec(exec_id, conn)) end)
def handle_call({:exec_start, exec_id}, from, state) do
Task.async(fn -> GenServer.reply(from, Api.start_exec(exec_id, state.conn)) end)
{:noreply, state}
end

@impl true
def handle_call({:exec_inspect, exec_id}, from, %{conn: conn} = state) do
Task.async(fn -> GenServer.reply(from, Api.inspect_exec(exec_id, conn)) end)
def handle_call({:exec_inspect, exec_id}, from, state) do
Task.async(fn -> GenServer.reply(from, Api.inspect_exec(exec_id, state.conn)) end)
{:noreply, state}
end
end

0 comments on commit 9de0a23

Please sign in to comment.