-module(testcontainers_gleam). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -define(FILEPATH, "src/testcontainers_gleam.gleam"). -export([stop_container/1, start_container/1]). -export_type([config/0, start_info/0, container/0]). -type config() :: {config, binary(), integer()}. -type start_info() :: {start_info, binary(), integer()}. -type container() :: any(). -file("src/testcontainers_gleam.gleam", 47). -spec stop_container(binary()) -> gleam@erlang@atom:atom_(). stop_container(Container_id) -> 'Elixir.Testcontainers':stop_container(Container_id). -file("src/testcontainers_gleam.gleam", 63). -spec start_info_item( gleam@dict:dict(gleam@erlang@atom:atom_(), EGF), binary(), fun((EGF) -> {ok, EGI} | {error, list(EGJ)}) ) -> {ok, EGI} | {error, list(EGJ)}. start_info_item(Start_info, Key, Decoder) -> _pipe = Start_info, _pipe@1 = gleam_stdlib:map_get(_pipe, erlang:binary_to_atom(Key)), _pipe@2 = gleam@result:map_error(_pipe@1, fun(_) -> [] end), gleam@result:'try'(_pipe@2, Decoder). -file("src/testcontainers_gleam.gleam", 34). -spec get_port( gleam@dict:dict(gleam@erlang@atom:atom_(), gleam@dynamic:dynamic_()) ) -> {ok, integer()} | {error, nil}. get_port(Start_info) -> Port_pair@1 = case start_info_item( Start_info, <<"exposed_ports"/utf8>>, fun(Dynamic_exposed_ports) -> gleam@dynamic@decode:run( Dynamic_exposed_ports, gleam@dynamic@decode:list( gleam@dynamic@decode:list( {decoder, fun gleam@dynamic@decode:decode_int/1} ) ) ) end ) of {ok, [Port_pair]} -> Port_pair; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"testcontainers_gleam"/utf8>>, function => <<"get_port"/utf8>>, line => 35, value => _assert_fail, start => 895, 'end' => 1085, pattern_start => 906, pattern_end => 921}) end, case Port_pair@1 of [_, P] -> {ok, P}; _ -> {error, nil} end. -file("src/testcontainers_gleam.gleam", 17). -spec start_container(config()) -> start_info(). start_container(Config) -> case 'Elixir.Testcontainers':start_link() of {ok, _} -> nil; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"testcontainers_gleam"/utf8>>, function => <<"start_container"/utf8>>, line => 18, value => _assert_fail, start => 336, 'end' => 367, pattern_start => 347, pattern_end => 352}) end, Container = 'Elixir.Testcontainers.Container':new(erlang:element(2, Config)), Container@1 = 'Elixir.Testcontainers.Container':with_exposed_port( Container, erlang:element(3, Config) ), Start_info@1 = case 'Elixir.Testcontainers':start_container(Container@1) of {ok, Start_info} -> Start_info; _assert_fail@1 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"testcontainers_gleam"/utf8>>, function => <<"start_container"/utf8>>, line => 22, value => _assert_fail@1, start => 477, 'end' => 575, pattern_start => 488, pattern_end => 502}) end, Container_id@1 = case start_info_item( Start_info@1, <<"container_id"/utf8>>, fun(Dynamic_container_id) -> gleam@dynamic@decode:run( Dynamic_container_id, {decoder, fun gleam@dynamic@decode:decode_string/1} ) end ) of {ok, Container_id} -> Container_id; _assert_fail@2 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"testcontainers_gleam"/utf8>>, function => <<"start_container"/utf8>>, line => 25, value => _assert_fail@2, start => 579, 'end' => 744, pattern_start => 590, pattern_end => 606}) end, Port@1 = case get_port(Start_info@1) of {ok, Port} -> Port; _assert_fail@3 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"testcontainers_gleam"/utf8>>, function => <<"start_container"/utf8>>, line => 30, value => _assert_fail@3, start => 748, 'end' => 790, pattern_start => 759, pattern_end => 767}) end, {start_info, Container_id@1, Port@1}.