MCPcopy Create free account
hub / github.com/docker/secrets-engine / muxServer

Function muxServer

client/client_test.go:114–139  ·  view source on GitHub ↗
(t *testing.T, socketPath string, handlers []handler)

Source from the content-addressed store, hash-verified

112}
113
114func muxServer(t *testing.T, socketPath string, handlers []handler) {
115 t.Helper()
116 _ = os.Remove(socketPath)
117 require.NoError(t, os.MkdirAll(filepath.Dir(socketPath), 0o755))
118 listener, err := net.Listen("unix", socketPath)
119 require.NoError(t, err)
120 mux := http.NewServeMux()
121 for _, h := range handlers {
122 mux.Handle(h.pattern, h.handler)
123 }
124
125 server := &http.Server{Handler: mux}
126
127 go func() {
128 _ = server.Serve(listener)
129 }()
130
131 t.Cleanup(func() {
132 shutdownCtx, cancel := context.WithTimeout(t.Context(), 5*time.Second)
133 defer cancel()
134
135 _ = server.Shutdown(shutdownCtx)
136 _ = listener.Close()
137 _ = os.RemoveAll(socketPath)
138 })
139}
140
141func wrapHandler(pattern string, h http.Handler) handler {
142 return handler{pattern: pattern, handler: h}

Callers 2

mockVersionEngineFunction · 0.85
mockListPluginsEngineFunction · 0.85

Calls 3

HandleMethod · 0.80
ShutdownMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected