@@ -21,10 +21,10 @@ defmodule Testcontainers.ContainerTest do
2121 container2 = ContainerBuilder . build ( Testcontainers.PostgresContainer . new ( ) )
2222
2323 assert Testcontainers.Util.Hash . struct_to_hash ( container1 ) ==
24- "2ac8f31c61b760b17176a9b9e51bd9d969eb26adadc9bf3db4cdcac69cfb065f "
24+ "082851e217cae88e1684169a9759a6d702d012016054c14b23d192f7e2559c63 "
2525
2626 assert Testcontainers.Util.Hash . struct_to_hash ( container2 ) ==
27- "2ac8f31c61b760b17176a9b9e51bd9d969eb26adadc9bf3db4cdcac69cfb065f "
27+ "082851e217cae88e1684169a9759a6d702d012016054c14b23d192f7e2559c63 "
2828 end
2929 end
3030
@@ -34,7 +34,7 @@ defmodule Testcontainers.ContainerTest do
3434 Container . new ( "my-image" )
3535 |> Container . with_exposed_port ( 80 )
3636
37- assert container . exposed_ports == [ 80 ]
37+ assert container . exposed_ports == [ { 80 , nil } ]
3838 end
3939
4040 test "removes duplicate exposed ports" do
@@ -43,7 +43,7 @@ defmodule Testcontainers.ContainerTest do
4343 |> Container . with_exposed_port ( 80 )
4444 |> Container . with_exposed_port ( 80 )
4545
46- assert container . exposed_ports == [ 80 ]
46+ assert container . exposed_ports == [ { 80 , nil } ]
4747 end
4848 end
4949
@@ -53,7 +53,7 @@ defmodule Testcontainers.ContainerTest do
5353 Container . new ( "my-image" )
5454 |> Container . with_exposed_ports ( [ 80 , 443 ] )
5555
56- assert container . exposed_ports == [ 80 , 443 ]
56+ assert container . exposed_ports == [ { 80 , nil } , { 443 , nil } ]
5757 end
5858
5959 test "removes duplicate exposed ports" do
@@ -62,7 +62,7 @@ defmodule Testcontainers.ContainerTest do
6262 |> Container . with_exposed_ports ( [ 80 , 443 ] )
6363 |> Container . with_exposed_ports ( [ 80 ] )
6464
65- assert container . exposed_ports == [ 80 , 443 ]
65+ assert container . exposed_ports == [ { 80 , nil } , { 443 , nil } ]
6666 end
6767 end
6868
@@ -96,6 +96,11 @@ defmodule Testcontainers.ContainerTest do
9696 container = Container . new ( "my-image" )
9797 assert Container . mapped_port ( container , 80 ) == nil
9898 end
99+
100+ test "returns nil (and does not crash) if the exposed port is present but not mapped (integer)" do
101+ container = Container . new ( "my-image" ) |> Container . with_exposed_port ( 80 )
102+ assert Container . mapped_port ( container , 80 ) == nil
103+ end
99104 end
100105
101106 describe "with_network_mode/2" do
0 commit comments