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

Function TestKillAll

pkg/compose/kill_test.go:36–73  ·  pkg/compose/kill_test.go::TestKillAll
(t *testing.T)

Source from the content-addressed store, hash-verified

34const testProject = "testProject"
35
36func TestKillAll(t *testing.T) {
37 mockCtrl := gomock.NewController(t)
38 defer mockCtrl.Finish()
39
40 api, cli := prepareMocks(mockCtrl)
41 tested, err := NewComposeService(cli)
42 assert.NilError(t, err)
43
44 name := strings.ToLower(testProject)
45
46 api.EXPECT().ContainerList(t.Context(), client.ContainerListOptions{
47 Filters: projectFilter(name).Add("label", compose.ConfigHashLabel),
48 }).Return(client.ContainerListResult{
49 Items: []container.Summary{
50 testContainer("service1", "123", false),
51 testContainer("service1", "456", false),
52 testContainer("service2", "789", false),
53 },
54 }, nil)
55 api.EXPECT().VolumeList(
56 gomock.Any(),
57 client.VolumeListOptions{
58 Filters: projectFilter(strings.ToLower(testProject)),
59 }).
60 Return(client.VolumeListResult{}, nil)
61 api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{Filters: projectFilter(strings.ToLower(testProject))}).
62 Return(client.NetworkListResult{
63 Items: []network.Summary{{
64 Network: network.Network{ID: "abc123", Name: "testProject_default"},
65 }},
66 }, nil)
67 api.EXPECT().ContainerKill(anyCancellableContext(), "123", client.ContainerKillOptions{}).Return(client.ContainerKillResult{}, nil)
68 api.EXPECT().ContainerKill(anyCancellableContext(), "456", client.ContainerKillOptions{}).Return(client.ContainerKillResult{}, nil)
69 api.EXPECT().ContainerKill(anyCancellableContext(), "789", client.ContainerKillOptions{}).Return(client.ContainerKillResult{}, nil)
70
71 err = tested.Kill(t.Context(), name, compose.KillOptions{})
72 assert.NilError(t, err)
73}
74
75func TestKillSignal(t *testing.T) {
76 const serviceName = "service1"

Callers

nothing calls this directly

Calls 12

prepareMocksFunction · 0.85
NewComposeServiceFunction · 0.85
projectFilterFunction · 0.85
testContainerFunction · 0.85
anyCancellableContextFunction · 0.85
KillMethod · 0.65
ContainerListMethod · 0.45
EXPECTMethod · 0.45
AddMethod · 0.45
VolumeListMethod · 0.45
NetworkListMethod · 0.45
ContainerKillMethod · 0.45

Tested by

no test coverage detected