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

Function TestTraversalWithMultipleParents

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

Source from the content-addressed store, hash-verified

53}
54
55func TestTraversalWithMultipleParents(t *testing.T) {
56 dependent := types.ServiceConfig{
57 Name: "dependent",
58 DependsOn: make(types.DependsOnConfig),
59 }
60
61 project := types.Project{
62 Services: types.Services{"dependent": dependent},
63 }
64
65 for i := 1; i <= 100; i++ {
66 name := fmt.Sprintf("svc_%d", i)
67 dependent.DependsOn[name] = types.ServiceDependency{}
68
69 svc := types.ServiceConfig{Name: name}
70 project.Services[name] = svc
71 }
72
73 svc := make(chan string, 10)
74 seen := make(map[string]int)
75 done := make(chan struct{})
76 go func() {
77 for service := range svc {
78 seen[service]++
79 }
80 done <- struct{}{}
81 }()
82
83 err := InDependencyOrder(t.Context(), &project, func(ctx context.Context, service string) error {
84 svc <- service
85 return nil
86 })
87 assert.NilError(t, err, "Error during iteration")
88 close(svc)
89 <-done
90
91 assert.Check(t, is.Len(seen, 101))
92 for svc, count := range seen {
93 assert.Equal(t, 1, count, "Service: %s", svc)
94 }
95}
96
97func TestInDependencyUpCommandOrder(t *testing.T) {
98 var order []string

Callers

nothing calls this directly

Calls 2

InDependencyOrderFunction · 0.85
LenMethod · 0.80

Tested by

no test coverage detected