Files
moby/internal/testutil/daemon/container.go
Sebastiaan van Stijn d3e45f8743 testutil: move back to internal
This package was originally internal, but was moved out when BuildKit
used it for its integration tests. That's no longer the case, so we
can make it internal again.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 10:08:30 +02:00

26 lines
546 B
Go

package daemon
import (
"context"
"testing"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
)
// ActiveContainers returns the list of ids of the currently running containers
func (d *Daemon) ActiveContainers(ctx context.Context, t testing.TB) []string {
t.Helper()
cli := d.NewClientT(t)
defer cli.Close()
containers, err := cli.ContainerList(context.Background(), client.ContainerListOptions{})
assert.NilError(t, err)
ids := make([]string, len(containers))
for i, c := range containers {
ids[i] = c.ID
}
return ids
}