From 38efa7d385b50d5c978f7a0c827766d6b79eb96e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarl=20Andr=C3=A9=20H=C3=BCbenthal?= Date: Fri, 13 Oct 2023 07:02:18 +0200 Subject: [PATCH] remove macro --- lib/ex_unit.ex | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/ex_unit.ex b/lib/ex_unit.ex index 347f3e7..c648b28 100644 --- a/lib/ex_unit.ex +++ b/lib/ex_unit.ex @@ -5,20 +5,18 @@ defmodule TestcontainersElixir.ExUnit do alias DockerEngineAPI.Api alias DockerEngineAPI.Model - defmacro container(options \\ []) do - quote do - docker_url = "http+unix://%2Fvar%2Frun%2Fdocker.sock/v1.43" - conn = Connection.new(base_url: docker_url) - image = Keyword.get(unquote(options), :image, nil) - port = Keyword.get(unquote(options), :port, nil) + def container(options \\ []) do + docker_url = "http+unix://%2Fvar%2Frun%2Fdocker.sock/v1.43" + conn = Connection.new(base_url: docker_url) + image = Keyword.get(options, :image, nil) + port = Keyword.get(options, :port, nil) - with {:ok, _} <- Api.Image.image_create(conn, fromImage: image), - {:ok, container} <- simple_container(conn, image, port), - container_id = container."Id", - :ok <- reap_container(conn, container_id), - {:ok, _} <- Api.Container.container_start(conn, container_id) do - {:ok, container_id} - end + with {:ok, _} <- Api.Image.image_create(conn, fromImage: image), + {:ok, container} <- simple_container(conn, image, port), + container_id = container."Id", + :ok <- reap_container(conn, container_id), + {:ok, _} <- Api.Container.container_start(conn, container_id) do + {:ok, container_id} end end