mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: refactor ContainerList to wrap result
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
This commit is contained in:
@@ -382,12 +382,12 @@ func createServices(ctx context.Context, t *testing.T, d *daemon.Daemon, section
|
||||
}
|
||||
|
||||
func pollService(ctx context.Context, t *testing.T, c *client.Client, host networking.Host) poll.Result {
|
||||
cl, err := c.ContainerList(ctx, client.ContainerListOptions{})
|
||||
list, err := c.ContainerList(ctx, client.ContainerListOptions{})
|
||||
if err != nil {
|
||||
return poll.Error(fmt.Errorf("failed to list containers: %w", err))
|
||||
}
|
||||
if len(cl) != 1 {
|
||||
return poll.Continue("got %d containers, want 1", len(cl))
|
||||
if len(list.Items) != 1 {
|
||||
return poll.Continue("got %d containers, want 1", len(list.Items))
|
||||
}
|
||||
// The DOCKER-INGRESS chain seems to be created, then populated, a few
|
||||
// milliseconds after the container starts. So, also wait for a conntrack
|
||||
|
||||
@@ -89,12 +89,12 @@ func TestHostPortMappings(t *testing.T) {
|
||||
|
||||
poll.WaitOn(t, swarm.RunningTasksCount(ctx, apiClient, svcID, 1), swarm.ServicePoll)
|
||||
|
||||
ctrs, err := apiClient.ContainerList(ctx, client.ContainerListOptions{})
|
||||
list, err := apiClient.ContainerList(ctx, client.ContainerListOptions{})
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, 1, len(ctrs))
|
||||
assert.Equal(t, 1, len(list.Items))
|
||||
|
||||
var addrs []string
|
||||
for _, port := range ctrs[0].Ports {
|
||||
for _, port := range list.Items[0].Ports {
|
||||
addrs = append(addrs, fmt.Sprintf("%s:%d/%s", net.JoinHostPort(port.IP.String(), strconv.Itoa(int(port.PublicPort))), port.PrivatePort, port.Type))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user