MCPcopy
hub / github.com/docker/compose / RequireServiceState

Function RequireServiceState

pkg/e2e/assert.go:30–43  ·  view source on GitHub ↗

RequireServiceState ensures that the container is in the expected state (running or exited).

(t testing.TB, cli *CLI, service string, state string)

Source from the content-addressed store, hash-verified

28// RequireServiceState ensures that the container is in the expected state
29// (running or exited).
30func RequireServiceState(t testing.TB, cli *CLI, service string, state string) {
31 t.Helper()
32 psRes := cli.RunDockerComposeCmd(t, "ps", "--all", "--format=json", service)
33 var svc map[string]any
34 assert.NilError(t, json.Unmarshal([]byte(psRes.Stdout()), &svc),
35 "Invalid `compose ps` JSON: command output: %s",
36 psRes.Combined())
37
38 assert.Assert(t, is.Equal(service, svc["Service"]), "Found ps output for unexpected service")
39 assert.Assert(t, is.Equal(strings.ToLower(state), strings.ToLower(svc["State"].(string))),
40 "Service %q (%s) not in expected state",
41 service, svc["Name"],
42 )
43}

Callers 2

TestRecreateWithNoDepsFunction · 0.85

Calls 1

RunDockerComposeCmdMethod · 0.80

Tested by 2

TestRecreateWithNoDepsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…