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

Function TestHandleHook_AppIDEncodedInURL

cmd/compose/hooks_test.go:175–196  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

173}
174
175func TestHandleHook_AppIDEncodedInURL(t *testing.T) {
176 prev := resolveAppID
177 t.Cleanup(func() { resolveAppID = prev })
178 resolveAppID = func(context.Context, map[string]string) string { return "myapp" }
179
180 t.Setenv("NO_COLOR", "1") // emit a plain URL we can substring-match
181 for _, rootCmd := range []string{"compose logs", "compose up"} {
182 t.Run(rootCmd, func(t *testing.T) {
183 data := marshalHookData(t, hooks.Request{
184 RootCmd: rootCmd,
185 Flags: map[string]string{"d": "true"},
186 })
187 var buf bytes.Buffer
188 err := handleHook(t.Context(), []string{data}, &buf)
189 assert.NilError(t, err)
190
191 msg := unmarshalResponse(t, buf.Bytes())
192 assert.Assert(t, strings.Contains(msg.Template, desktop.BuildLogsURL("myapp")),
193 "hint should include the project-scoped URL, got %q", msg.Template)
194 })
195 }
196}
197
198func TestHandleHook_DockerLogsIgnoresAppID(t *testing.T) {
199 // resolveAppID is not consulted for "logs" because that hint isn't

Callers

nothing calls this directly

Calls 5

BuildLogsURLFunction · 0.92
marshalHookDataFunction · 0.85
handleHookFunction · 0.85
unmarshalResponseFunction · 0.85
BytesMethod · 0.80

Tested by

no test coverage detected