-module(efka_docker_container_builder_tests). -include_lib("eunit/include/eunit.hrl"). port_bindings_are_rendered_for_docker_create_test() -> Name = <<"nginx">>, ContainerDir = "/tmp/efka-nginx/", Create = #{ <<"config">> => #{ <<"image">> => <<"nginx:latest">>, <<"exposed_ports">> => [ #{<<"container_port">> => 80, <<"protocol">> => <<"tcp">>}, #{<<"container_port">> => 443, <<"protocol">> => <<"tcp">>} ] }, <<"host_config">> => #{ <<"port_bindings">> => [ #{<<"host_ip">> => <<>>, <<"host_port">> => 8080, <<"container_port">> => 80, <<"protocol">> => <<"tcp">>}, #{<<"host_ip">> => <<>>, <<"host_port">> => 443, <<"container_port">> => 443, <<"protocol">> => <<"tcp">>} ] } }, Options = docker_container_builder:build_options(Name, ContainerDir, Create), ?assertMatch(#{ <<"ExposedPorts">> := #{ <<"80/tcp">> := #{}, <<"443/tcp">> := #{} }, <<"HostConfig">> := #{ <<"PortBindings">> := #{ <<"80/tcp">> := [#{<<"HostIp">> := <<>>, <<"HostPort">> := <<"8080">>}], <<"443/tcp">> := [#{<<"HostIp">> := <<>>, <<"HostPort">> := <<"443">>}] } } }, Options).