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

Function newPreStartTestService

pkg/compose/pre_start_test.go:36–57  ·  pkg/compose/pre_start_test.go::newPreStartTestService
(t *testing.T)

Source from the content-addressed store, hash-verified

34)
35
36func newPreStartTestService(t *testing.T) (*composeService, *mocks.MockAPIClient) {
37 t.Helper()
38 // Register the goroutine-leak check first so it runs last (t.Cleanup is
39 // LIFO), after gomock's own cleanup has drained any internal goroutines.
40 // Any goroutine spawned by the code under test that outlives the test will
41 // fail this assertion.
42 ignoreExisting := goleak.IgnoreCurrent()
43 t.Cleanup(func() {
44 goleak.VerifyNone(t, ignoreExisting)
45 })
46 mockCtrl := gomock.NewController(t)
47 t.Cleanup(mockCtrl.Finish)
48 apiClient := mocks.NewMockAPIClient(mockCtrl)
49 cli := mocks.NewMockCli(mockCtrl)
50 cli.EXPECT().Client().Return(apiClient).AnyTimes()
51 apiClient.EXPECT().Ping(gomock.Any(), client.PingOptions{NegotiateAPIVersion: true}).
52 Return(client.PingResult{APIVersion: "1.44"}, nil).AnyTimes()
53 apiClient.EXPECT().ClientVersion().Return("1.44").AnyTimes()
54 tested, err := NewComposeService(cli)
55 assert.NilError(t, err)
56 return tested.(*composeService), apiClient
57}
58
59func waitResultExit(code int64) client.ContainerWaitResult {
60 resultC := make(chan container.WaitResponse, 1)

Calls 8

EXPECTMethod · 0.95
EXPECTMethod · 0.95
NewMockAPIClientFunction · 0.92
NewMockCliFunction · 0.92
NewComposeServiceFunction · 0.85
ClientMethod · 0.45
PingMethod · 0.45
ClientVersionMethod · 0.45

Tested by

no test coverage detected