MCPcopy
hub / github.com/basecamp/once / countContainers

Function countContainers

integration/docker_test.go:960–980  ·  view source on GitHub ↗
(t *testing.T, ctx context.Context, prefix string)

Source from the content-addressed store, hash-verified

958}
959
960func countContainers(t *testing.T, ctx context.Context, prefix string) int {
961 t.Helper()
962 c, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
963 require.NoError(t, err)
964 defer c.Close()
965
966 containers, err := c.ContainerList(ctx, container.ListOptions{All: true})
967 require.NoError(t, err)
968
969 count := 0
970 for _, ctr := range containers {
971 if len(ctr.Names) == 0 {
972 continue
973 }
974 name := strings.TrimPrefix(ctr.Names[0], "/")
975 if strings.HasPrefix(name, prefix) {
976 count++
977 }
978 }
979 return count
980}
981
982func execInContainer(t *testing.T, ctx context.Context, containerName string, cmd []string) {
983 t.Helper()

Callers 3

TestGaplessDeploymentFunction · 0.85
TestRemoveApplicationFunction · 0.85

Calls 2

ContainerListMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…