MCPcopy Create free account
hub / github.com/docker/compose / TestContainersToStacks

Function TestContainersToStacks

pkg/compose/ls_test.go:29–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27)
28
29func TestContainersToStacks(t *testing.T) {
30 containers := []container.Summary{
31 {
32 ID: "service1",
33 State: "running",
34 Labels: map[string]string{api.ProjectLabel: "project1", api.ConfigFilesLabel: "/home/docker-compose.yaml"},
35 },
36 {
37 ID: "service2",
38 State: "running",
39 Labels: map[string]string{api.ProjectLabel: "project1", api.ConfigFilesLabel: "/home/docker-compose.yaml"},
40 },
41 {
42 ID: "service3",
43 State: "running",
44 Labels: map[string]string{api.ProjectLabel: "project2", api.ConfigFilesLabel: "/home/project2-docker-compose.yaml"},
45 },
46 }
47 stacks, err := containersToStacks(containers)
48 assert.NilError(t, err)
49 assert.DeepEqual(t, stacks, []api.Stack{
50 {
51 ID: "project1",
52 Name: "project1",
53 Status: "running(2)",
54 ConfigFiles: "/home/docker-compose.yaml",
55 },
56 {
57 ID: "project2",
58 Name: "project2",
59 Status: "running(1)",
60 ConfigFiles: "/home/project2-docker-compose.yaml",
61 },
62 })
63}
64
65func TestStacksMixedStatus(t *testing.T) {
66 assert.Equal(t, combinedStatus([]string{"running"}), "running(1)")

Callers

nothing calls this directly

Calls 1

containersToStacksFunction · 0.85

Tested by

no test coverage detected