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

Function TestWaitDependencies

pkg/compose/convergence_test.go:222–258  ·  pkg/compose/convergence_test.go::TestWaitDependencies
(t *testing.T)

Source from the content-addressed store, hash-verified

220}
221
222func TestWaitDependencies(t *testing.T) {
223 mockCtrl := gomock.NewController(t)
224 defer mockCtrl.Finish()
225
226 apiClient := mocks.NewMockAPIClient(mockCtrl)
227 cli := mocks.NewMockCli(mockCtrl)
228 tested, err := NewComposeService(cli)
229 assert.NilError(t, err)
230 cli.EXPECT().Client().Return(apiClient).AnyTimes()
231
232 t.Run("should skip dependencies with scale 0", func(t *testing.T) {
233 dbService := types.ServiceConfig{Name: "db", Scale: intPtr(0)}
234 redisService := types.ServiceConfig{Name: "redis", Scale: intPtr(0)}
235 project := types.Project{Name: strings.ToLower(testProject), Services: types.Services{
236 "db": dbService,
237 "redis": redisService,
238 }}
239 dependencies := types.DependsOnConfig{
240 "db": {Condition: ServiceConditionRunningOrHealthy},
241 "redis": {Condition: ServiceConditionRunningOrHealthy},
242 }
243 assert.NilError(t, tested.(*composeService).waitDependencies(t.Context(), &project, "", dependencies, nil, 0))
244 })
245 t.Run("should skip dependencies with condition service_started", func(t *testing.T) {
246 dbService := types.ServiceConfig{Name: "db", Scale: intPtr(1)}
247 redisService := types.ServiceConfig{Name: "redis", Scale: intPtr(1)}
248 project := types.Project{Name: strings.ToLower(testProject), Services: types.Services{
249 "db": dbService,
250 "redis": redisService,
251 }}
252 dependencies := types.DependsOnConfig{
253 "db": {Condition: types.ServiceConditionStarted, Required: true},
254 "redis": {Condition: types.ServiceConditionStarted, Required: true},
255 }
256 assert.NilError(t, tested.(*composeService).waitDependencies(t.Context(), &project, "", dependencies, nil, 0))
257 })
258}
259
260func TestIsServiceHealthy(t *testing.T) {
261 mockCtrl := gomock.NewController(t)

Callers

nothing calls this directly

Calls 7

EXPECTMethod · 0.95
NewMockAPIClientFunction · 0.92
NewMockCliFunction · 0.92
NewComposeServiceFunction · 0.85
intPtrFunction · 0.85
waitDependenciesMethod · 0.80
ClientMethod · 0.45

Tested by

no test coverage detected