Skip to content

Commit

Permalink
use docker-engine-api and make test
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlah committed Oct 11, 2023
1 parent e804f07 commit cd408b3
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 105 deletions.
2 changes: 0 additions & 2 deletions gleam.toml

This file was deleted.

27 changes: 24 additions & 3 deletions lib/testcontainers_elixir.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,29 @@ defmodule TestcontainersElixir do
"""

def hello do
:hello.parse_docker_host(System.get_env("DOCKER_HOST", ""))
|> IO.inspect()
:hello.fetch_hello("world")
DockerEngineAPI.Connection.new(
base_url: base_url()
)
|> DockerEngineAPI.Api.Image.image_list()
end

@socket_path "unix:///var/run/docker.sock"
@default_version "v1.43"

defp base_url() do
host = Application.get_env(:docker, :host) || System.get_env("DOCKER_HOST", @socket_path)
version =
case Application.get_env(:docker, :version) do
nil -> @default_version
version -> version
end


"#{normalize_host(host)}/#{version}"
|> String.trim_trailing("/")
end

defp normalize_host("tcp://" <> host), do: "http://" <> host
defp normalize_host("unix://" <> host), do: "http+unix://" <> URI.encode_www_form(host)

end
21 changes: 0 additions & 21 deletions manifest.toml

This file was deleted.

26 changes: 3 additions & 23 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Meetup.MixProject do
defmodule TestcontainersElixir.MixProject do
use Mix.Project

@app :testcontainers_elixir
Expand All @@ -9,20 +9,7 @@ defmodule Meetup.MixProject do
app: @app,
version: @version,
elixir: "~> 1.15",
elixirc_paths: elixirc_paths(Mix.env()),
name: "#{@app}",
archives: [mix_gleam: "~> 0.6.1"],
compilers: [:gleam | Mix.compilers()],
aliases: [
"deps.get": ["deps.get", "gleam.deps.get"]
],
erlc_paths: [
"build/dev/erlang/#{@app}/_gleam_artefacts",
# For Gleam < v0.25.0
"build/dev/erlang/#{@app}/build"
],
erlc_include_path: "build/dev/erlang/#{@app}/include",
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps()
]
Expand All @@ -37,20 +24,13 @@ defmodule Meetup.MixProject do
]
end

# Specifies which paths to compile per environment.
# , "test/support"]
defp elixirc_paths(:test), do: ["lib"]
defp elixirc_paths(_), do: ["lib"]

# Specifies your project dependencies.
#
# Type `mix help deps` for examples and options.
defp deps do
[
{:mix_gleam, "~> 0.6"},
{:gleam_hackney, "~> 1.1"},
{:gleam_http, "~> 3.5"},
{:ex_license, "~> 0.1.0"}
{:ex_license, "~> 0.1.0"},
{:docker_engine_api, git: "https://github.com/jarlah/docker-engine-api.git", tag: "1.43.0-hackney"}
]
end

Expand Down
9 changes: 8 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
%{
"certifi": {:hex, :certifi, "2.12.0", "2d1cca2ec95f59643862af91f001478c9863c2ac9cb6e2f89780bfd8de987329", [:rebar3], [], "hexpm", "ee68d85df22e554040cdb4be100f33873ac6051387baf6a8f6ce82272340ff1c"},
"docker": {:git, "https://github.com/hexedpackets/docker-elixir.git", "b4f8b929691ce2bf9f11743def49009de460431b", [tag: "0.4.0"]},
"docker_api": {:git, "https://github.com/hexedpackets/docker-elixir.git", "b4f8b929691ce2bf9f11743def49009de460431b", [tag: "0.4.0"]},
"docker_engine_api": {:git, "https://github.com/jarlah/docker-engine-api.git", "12247693d92eaa48d4470648508762ff98bf9680", [tag: "1.43.0-hackney"]},
"ex_license": {:hex, :ex_license, "0.1.1", "bbdaba704f861894da3ae80e4399984379f19de1cca4ecf7d799616c832b8821", [:mix], [], "hexpm", "dd95aaaba0c9c6f0e9be2db3e9fac0bf69784557e04f700f94e90629f5e24e1d"},
"gleam_fetch": {:hex, :gleam_fetch, "0.2.1", "ae5b960e62858354e1f075d6c857730648218b18ef1f13b5dc93f15e109767ca", [:gleam], [{:gleam_http, "~> 3.1", [hex: :gleam_http, repo: "hexpm", optional: false]}, {:gleam_javascript, "~> 0.3", [hex: :gleam_javascript, repo: "hexpm", optional: false]}, {:gleam_stdlib, "~> 0.31", [hex: :gleam_stdlib, repo: "hexpm", optional: false]}], "hexpm", "f64e93c754d948b2d37abc4add5482fe0faed4b99c79e66012dde96bedc40544"},
"gleam_hackney": {:hex, :gleam_hackney, "1.1.0", "f6b1e413490b0214f0f1c3f2a8d720ee2149329e18a632d91c5657bbe3aad964", [:gleam], [{:gleam_http, "~> 3.0", [hex: :gleam_http, repo: "hexpm", optional: false]}, {:gleam_stdlib, "~> 0.18", [hex: :gleam_stdlib, repo: "hexpm", optional: false]}, {:hackney, "~> 1.18", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "ca69ad9061c4a8775a7bd445de33ecefd87379af8e5b028f3dd0216beca5dd0b"},
"gleam_http": {:hex, :gleam_http, "3.5.0", "a81baa9762a4fa763dcf4abd8a6c8a9979d9464957187b440a609492e6edf4ce", [:gleam], [{:gleam_stdlib, "~> 0.18", [hex: :gleam_stdlib, repo: "hexpm", optional: false]}], "hexpm", "fae9ae3eb1ca90c2194615d20fffd1e28b630e84daca670b28d959b37bcbb02c"},
"gleam_javascript": {:hex, :gleam_javascript, "0.6.1", "11905461026750b61177ca911e87b49edff6e2384c98c4d78d074029f8fd83e8", [:gleam], [{:gleam_stdlib, "~> 0.19", [hex: :gleam_stdlib, repo: "hexpm", optional: false]}], "hexpm", "bfebb63abe4a1694e07defd19b160c2980304b5d775a89d4b02e7de7c9d8008b"},
"gleam_stdlib": {:hex, :gleam_stdlib, "0.31.0", "128cbff56a6a5fd4b53b6eafb2d87a8b53ce00957bc27789055d9e53eff88118", [:gleam], [], "hexpm", "6d1bc5b4d4179b9fee866b1e69fe180ac2ce485ad90047c0b32b2ca984052736"},
"gleeunit": {:hex, :gleeunit, "0.11.0", "2008028d27f2fec9c055883a9f100dd1672584e583c7386ee67b5aeae263520f", [:gleam], [{:gleam_stdlib, "~> 0.27", [hex: :gleam_stdlib, repo: "hexpm", optional: false]}], "hexpm", "1397e5c4ac4108769ee979939ac39bf7870659c5afb714630deeee16b8272ad5"},
"hackney": {:hex, :hackney, "1.20.0", "299bb56c21d08dbf86da44a9733eb926062a00045b5ba4912f5d209b36f3f418", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "8cee84c3bbe32f148d45806f8084537e8b181f70c9bf69814fc24105f5b04fb6"},
"hackney": {:hex, :hackney, "1.20.1", "8d97aec62ddddd757d128bfd1df6c5861093419f8f7a4223823537bad5d064e2", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fe9094e5f1a2a2c0a7d10918fee36bfec0ec2a979994cff8cfe8058cd9af38e3"},
"idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
"mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
"mix_gleam": {:hex, :mix_gleam, "0.6.1", "d701fb4f9d97c786c09910f71a5441a11ef435fc09eeed67e60e90c2c92f21cf", [:mix], [], "hexpm", "3db42d762fa9bbff1cb69f57ba3f2063130742b6b5a7ab06759cc45f2c8f74ab"},
"parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"},
"poison": {:hex, :poison, "5.0.0", "d2b54589ab4157bbb82ec2050757779bfed724463a544b6e20d79855a9e43b24", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "11dc6117c501b80c62a7594f941d043982a1bd05a1184280c0d9166eb4d8d3fc"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},
"tesla": {:hex, :tesla, "1.7.0", "a62dda2f80d4f8a925eb7b8c5b78c461e0eb996672719fe1a63b26321a5f8b4e", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:finch, "~> 0.13", [hex: :finch, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:gun, "~> 1.3", [hex: :gun, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:msgpax, "~> 2.3", [hex: :msgpax, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "2e64f01ebfdb026209b47bc651a0e65203fcff4ae79c11efb73c4852b00dc313"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
}
53 changes: 0 additions & 53 deletions src/hello.gleam

This file was deleted.

1 change: 0 additions & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# do i need this file?
ExUnit.start()
3 changes: 2 additions & 1 deletion test/testcontainers_elixir_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ defmodule TestcontainersElixirTest do
doctest TestcontainersElixir

test "greets the world" do
assert TestcontainersElixir.hello() == "{\"message\":\"Hello World\"}"
{:ok, list} = TestcontainersElixir.hello()
assert is_number(length(list))
end
end

0 comments on commit cd408b3

Please sign in to comment.