(t *testing.T)
| 220 | } |
| 221 | |
| 222 | func 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 | |
| 260 | func TestIsServiceHealthy(t *testing.T) { |
| 261 | mockCtrl := gomock.NewController(t) |
nothing calls this directly
no test coverage detected