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

Function TestHandleHook_ComposeUpDetached

cmd/compose/hooks_test.go:95–140  ·  cmd/compose/hooks_test.go::TestHandleHook_ComposeUpDetached
(t *testing.T)

Source from the content-addressed store, hash-verified

93}
94
95func TestHandleHook_ComposeUpDetached(t *testing.T) {
96 tests := []struct {
97 name string
98 flags map[string]string
99 wantHint bool
100 }{
101 {
102 name: "with --detach flag",
103 flags: map[string]string{"detach": ""},
104 wantHint: true,
105 },
106 {
107 name: "with -d flag",
108 flags: map[string]string{"d": ""},
109 wantHint: true,
110 },
111 {
112 name: "without detach flag",
113 flags: map[string]string{"build": ""},
114 wantHint: false,
115 },
116 {
117 name: "no flags",
118 flags: map[string]string{},
119 wantHint: false,
120 },
121 }
122 for _, tt := range tests {
123 t.Run(tt.name, func(t *testing.T) {
124 data := marshalHookData(t, hooks.Request{
125 RootCmd: "compose up",
126 Flags: tt.flags,
127 })
128 var buf bytes.Buffer
129 err := handleHook(t.Context(), []string{data}, &buf)
130 assert.NilError(t, err)
131
132 if tt.wantHint {
133 msg := unmarshalResponse(t, buf.Bytes())
134 assert.Equal(t, msg.Template, composeLogsHint(""))
135 } else {
136 assert.Equal(t, buf.String(), "")
137 }
138 })
139 }
140}
141
142func TestHandleHook_HintContainsOSC8Link(t *testing.T) {
143 // Ensure ANSI is not suppressed by the test runner environment

Callers

nothing calls this directly

Calls 6

marshalHookDataFunction · 0.85
handleHookFunction · 0.85
unmarshalResponseFunction · 0.85
composeLogsHintFunction · 0.85
BytesMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected