MCPcopy Create free account
hub / github.com/docker/compose / TestShouldFollowStartEvent

Function TestShouldFollowStartEvent

pkg/compose/up_test.go:27–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestShouldFollowStartEvent(t *testing.T) {
28 tests := []struct {
29 name string
30 event api.ContainerEvent
31 attached []string
32 attachTo []string
33 want bool
34 }{
35 {
36 name: "ignores non-start events",
37 event: api.ContainerEvent{
38 Type: api.ContainerEventExited,
39 Service: "validator",
40 },
41 attachTo: []string{"validator"},
42 want: false,
43 },
44 {
45 name: "ignores services outside explicit attach selection",
46 event: api.ContainerEvent{
47 Type: api.ContainerEventStarted,
48 Service: "event-bus-validator",
49 ID: "event-bus-validator-1",
50 },
51 attachTo: []string{"validator"},
52 want: false,
53 },
54 {
55 name: "ignores containers already attached unless restarting",
56 event: api.ContainerEvent{
57 Type: api.ContainerEventStarted,
58 Service: "validator",
59 ID: "validator-1",
60 },
61 attached: []string{"validator-1"},
62 attachTo: []string{"validator"},
63 want: false,
64 },
65 {
66 name: "follows restarts for attached service",
67 event: api.ContainerEvent{
68 Type: api.ContainerEventStarted,
69 Service: "validator",
70 ID: "validator-1",
71 Restarting: true,
72 },
73 attached: []string{"validator-1"},
74 attachTo: []string{"validator"},
75 want: true,
76 },
77 {
78 name: "follows selected service when not already attached",
79 event: api.ContainerEvent{
80 Type: api.ContainerEventStarted,
81 Service: "validator",
82 ID: "validator-2",
83 },
84 attachTo: []string{"validator"},

Callers

nothing calls this directly

Calls 1

shouldFollowStartEventFunction · 0.85

Tested by

no test coverage detected