-
-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* main: fix: missing image build errors (#2651) test: fix image label test (#2689) chore(deps): bump github.com/docker/docker from 27.0.3+incompatible to 27.1.0+incompatible (#2682) chore: print Docker Info labels in banner (#2681) fix: incorrect parsing of exposedPorts in readiness check (#2658)
- Loading branch information
Showing
103 changed files
with
307 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package testcontainers | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/docker/go-connections/nat" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestPortMappingCheck(t *testing.T) { | ||
makePortMap := func(ports ...string) nat.PortMap { | ||
out := make(nat.PortMap) | ||
for _, port := range ports { | ||
// We don't care about the actual binding in this test | ||
out[nat.Port(port)] = nil | ||
} | ||
return out | ||
} | ||
|
||
tests := map[string]struct { | ||
exposedAndMappedPorts nat.PortMap | ||
exposedPorts []string | ||
expectError bool | ||
}{ | ||
"no-protocol": { | ||
exposedAndMappedPorts: makePortMap("1024/tcp"), | ||
exposedPorts: []string{"1024"}, | ||
}, | ||
"protocol": { | ||
exposedAndMappedPorts: makePortMap("1024/tcp"), | ||
exposedPorts: []string{"1024/tcp"}, | ||
}, | ||
"protocol-target-port": { | ||
exposedAndMappedPorts: makePortMap("1024/tcp"), | ||
exposedPorts: []string{"1024:1024/tcp"}, | ||
}, | ||
"target-port": { | ||
exposedAndMappedPorts: makePortMap("1024/tcp"), | ||
exposedPorts: []string{"1024:1024"}, | ||
}, | ||
"multiple-ports": { | ||
exposedAndMappedPorts: makePortMap("1024/tcp", "1025/tcp", "1026/tcp"), | ||
exposedPorts: []string{"1024", "25:1025/tcp", "1026:1026"}, | ||
}, | ||
"only-ipv4": { | ||
exposedAndMappedPorts: makePortMap("1024/tcp"), | ||
exposedPorts: []string{"0.0.0.0::1024/tcp"}, | ||
}, | ||
"no-mapped-ports": { | ||
exposedAndMappedPorts: makePortMap(), | ||
exposedPorts: []string{"1024"}, | ||
expectError: true, | ||
}, | ||
"wrong-mapped-port": { | ||
exposedAndMappedPorts: makePortMap("1023/tcp"), | ||
exposedPorts: []string{"1024"}, | ||
expectError: true, | ||
}, | ||
"subset-mapped-ports": { | ||
exposedAndMappedPorts: makePortMap("1024/tcp", "1025/tcp"), | ||
exposedPorts: []string{"1024", "1025", "1026"}, | ||
expectError: true, | ||
}, | ||
} | ||
for name, tt := range tests { | ||
t.Run(name, func(t *testing.T) { | ||
err := checkPortsMapped(tt.exposedAndMappedPorts, tt.exposedPorts) | ||
if tt.expectError { | ||
require.Error(t, err) | ||
return | ||
} | ||
require.NoError(t, err) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.