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

Function TestExecutePlanStopRemoveContainer

pkg/compose/executor_test.go:89–122  ·  pkg/compose/executor_test.go::TestExecutePlanStopRemoveContainer
(t *testing.T)

Source from the content-addressed store, hash-verified

87}
88
89func TestExecutePlanStopRemoveContainer(t *testing.T) {
90 svc, apiClient := newTestService(t)
91
92 ctr := container.Summary{
93 ID: "c1",
94 Names: []string{"/test-web-1"},
95 Labels: map[string]string{
96 api.ServiceLabel: "web",
97 api.ContainerNumberLabel: "1",
98 },
99 }
100
101 apiClient.EXPECT().ContainerStop(gomock.Any(), "c1", gomock.Any()).
102 Return(client.ContainerStopResult{}, nil)
103 apiClient.EXPECT().ContainerRemove(gomock.Any(), "c1", gomock.Any()).
104 Return(client.ContainerRemoveResult{}, nil)
105
106 plan := &Plan{}
107 stopNode := plan.addNode(Operation{
108 Type: OpStopContainer,
109 ResourceID: "service:web:1",
110 Cause: "scale down",
111 Container: &ctr,
112 }, "")
113 plan.addNode(Operation{
114 Type: OpRemoveContainer,
115 ResourceID: "service:web:1",
116 Cause: "scale down",
117 Container: &ctr,
118 }, "", stopNode)
119
120 err := svc.executePlan(t.Context(), &types.Project{Name: "test"}, emptyObservedState("test"), plan)
121 assert.NilError(t, err)
122}
123
124// emptyObservedState returns an ObservedState with no containers/networks/volumes,
125// suitable for executor tests that don't exercise service-reference resolution.

Callers

nothing calls this directly

Calls 7

addNodeMethod · 0.95
newTestServiceFunction · 0.85
emptyObservedStateFunction · 0.85
executePlanMethod · 0.80
ContainerStopMethod · 0.45
EXPECTMethod · 0.45
ContainerRemoveMethod · 0.45

Tested by

no test coverage detected