(t *testing.T)
| 274 | } |
| 275 | |
| 276 | func TestBuildGraphDependsOn(t *testing.T) { |
| 277 | testCases := []struct { |
| 278 | desc string |
| 279 | services types.Services |
| 280 | expectedVertices map[string]*Vertex |
| 281 | }{ |
| 282 | { |
| 283 | desc: "service depends on init container which is already removed", |
| 284 | services: types.Services{ |
| 285 | "test": { |
| 286 | Name: "test", |
| 287 | DependsOn: types.DependsOnConfig{ |
| 288 | "test-removed-init-container": types.ServiceDependency{ |
| 289 | Condition: "service_completed_successfully", |
| 290 | Restart: false, |
| 291 | Extensions: types.Extensions(nil), |
| 292 | Required: false, |
| 293 | }, |
| 294 | }, |
| 295 | }, |
| 296 | }, |
| 297 | expectedVertices: map[string]*Vertex{ |
| 298 | "test": { |
| 299 | Key: "test", |
| 300 | Service: "test", |
| 301 | Status: ServiceStopped, |
| 302 | Children: map[string]*Vertex{}, |
| 303 | Parents: map[string]*Vertex{}, |
| 304 | }, |
| 305 | }, |
| 306 | }, |
| 307 | } |
| 308 | for _, tC := range testCases { |
| 309 | t.Run(tC.desc, func(t *testing.T) { |
| 310 | project := types.Project{ |
| 311 | Services: tC.services, |
| 312 | } |
| 313 | |
| 314 | graph, err := NewGraph(&project, ServiceStopped) |
| 315 | assert.NilError(t, err, fmt.Sprintf("failed to build graph for: %s", tC.desc)) |
| 316 | |
| 317 | for k, vertex := range graph.Vertices { |
| 318 | expected, ok := tC.expectedVertices[k] |
| 319 | assert.Equal(t, true, ok) |
| 320 | assert.Equal(t, true, isVertexEqual(*expected, *vertex)) |
| 321 | } |
| 322 | }) |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | func isVertexEqual(a, b Vertex) bool { |
| 327 | childrenEquality := true |
nothing calls this directly
no test coverage detected