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

Function TestStopTimeout

pkg/compose/stop_test.go:33–68  ·  pkg/compose/stop_test.go::TestStopTimeout
(t *testing.T)

Source from the content-addressed store, hash-verified

31)
32
33func TestStopTimeout(t *testing.T) {
34 mockCtrl := gomock.NewController(t)
35 defer mockCtrl.Finish()
36
37 api, cli := prepareMocks(mockCtrl)
38 tested, err := NewComposeService(cli)
39 assert.NilError(t, err)
40
41 api.EXPECT().ContainerList(gomock.Any(), projectFilterListOpt(false)).Return(
42 client.ContainerListResult{
43 Items: []container.Summary{
44 testContainer("service1", "123", false),
45 testContainer("service1", "456", false),
46 testContainer("service2", "789", false),
47 },
48 }, nil)
49 api.EXPECT().VolumeList(
50 gomock.Any(),
51 client.VolumeListOptions{
52 Filters: projectFilter(strings.ToLower(testProject)),
53 }).
54 Return(client.VolumeListResult{}, nil)
55 api.EXPECT().NetworkList(gomock.Any(), client.NetworkListOptions{Filters: projectFilter(strings.ToLower(testProject))}).
56 Return(client.NetworkListResult{}, nil)
57
58 timeout := 2 * time.Second
59 stopConfig := client.ContainerStopOptions{Timeout: utils.DurationSecondToInt(&timeout)}
60 api.EXPECT().ContainerStop(gomock.Any(), "123", stopConfig).Return(client.ContainerStopResult{}, nil)
61 api.EXPECT().ContainerStop(gomock.Any(), "456", stopConfig).Return(client.ContainerStopResult{}, nil)
62 api.EXPECT().ContainerStop(gomock.Any(), "789", stopConfig).Return(client.ContainerStopResult{}, nil)
63
64 err = tested.Stop(t.Context(), strings.ToLower(testProject), compose.StopOptions{
65 Timeout: &timeout,
66 })
67 assert.NilError(t, err)
68}

Callers

nothing calls this directly

Calls 12

DurationSecondToIntFunction · 0.92
prepareMocksFunction · 0.85
NewComposeServiceFunction · 0.85
projectFilterListOptFunction · 0.85
testContainerFunction · 0.85
projectFilterFunction · 0.85
StopMethod · 0.65
ContainerListMethod · 0.45
EXPECTMethod · 0.45
VolumeListMethod · 0.45
NetworkListMethod · 0.45
ContainerStopMethod · 0.45

Tested by

no test coverage detected