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

Function TestWith_RootNodesAndUp

pkg/compose/dependencies_test.go:345–428  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

343}
344
345func TestWith_RootNodesAndUp(t *testing.T) {
346 graph := &Graph{
347 lock: sync.RWMutex{},
348 Vertices: map[string]*Vertex{},
349 }
350
351 /** graph topology:
352 A B
353 / \ / \
354 G C E
355 \ /
356 D
357 |
358 F
359 */
360
361 graph.AddVertex("A", "A", 0)
362 graph.AddVertex("B", "B", 0)
363 graph.AddVertex("C", "C", 0)
364 graph.AddVertex("D", "D", 0)
365 graph.AddVertex("E", "E", 0)
366 graph.AddVertex("F", "F", 0)
367 graph.AddVertex("G", "G", 0)
368
369 _ = graph.AddEdge("C", "A")
370 _ = graph.AddEdge("C", "B")
371 _ = graph.AddEdge("E", "B")
372 _ = graph.AddEdge("D", "C")
373 _ = graph.AddEdge("D", "E")
374 _ = graph.AddEdge("F", "D")
375 _ = graph.AddEdge("G", "A")
376
377 tests := []struct {
378 name string
379 nodes []string
380 want []string
381 }{
382 {
383 name: "whole graph",
384 nodes: []string{"A", "B"},
385 want: []string{"A", "B", "C", "D", "E", "F", "G"},
386 },
387 {
388 name: "only leaves",
389 nodes: []string{"F", "G"},
390 want: []string{"F", "G"},
391 },
392 {
393 name: "simple dependent",
394 nodes: []string{"D"},
395 want: []string{"D", "F"},
396 },
397 {
398 name: "diamond dependents",
399 nodes: []string{"B"},
400 want: []string{"B", "C", "D", "E", "F"},
401 },
402 {

Callers

nothing calls this directly

Calls 7

AddVertexMethod · 0.95
AddEdgeMethod · 0.95
downDirectionTraversalFunction · 0.85
WithRootNodesAndDownFunction · 0.85
AddAllMethod · 0.80
LockMethod · 0.45
visitMethod · 0.45

Tested by

no test coverage detected