MCPcopy Create free account
hub / github.com/coder/envbuilder / New

Function New

testutil/registrytest/registrytest.go:35–46  ·  view source on GitHub ↗

New starts a new Docker registry listening on localhost. It will automatically shut down when the test finishes. It will store data in memory.

(t testing.TB, mws ...func(http.Handler) http.Handler)

Source from the content-addressed store, hash-verified

33// It will automatically shut down when the test finishes.
34// It will store data in memory.
35func New(t testing.TB, mws ...func(http.Handler) http.Handler) string {
36 t.Helper()
37 regHandler := registry.New(registry.WithBlobHandler(registry.NewInMemoryBlobHandler()))
38 for _, mw := range mws {
39 regHandler = mw(regHandler)
40 }
41 regSrv := httptest.NewServer(regHandler)
42 t.Cleanup(func() { regSrv.Close() })
43 regSrvURL, err := url.Parse(regSrv.URL)
44 require.NoError(t, err)
45 return fmt.Sprintf("localhost:%s", regSrvURL.Port())
46}
47
48// WriteContainer uploads a container to the registry server.
49// It returns the reference to the uploaded container.

Callers 7

TestPushImageFunction · 0.92
setupInMemoryRegistryFunction · 0.92
TestCompileWithFeaturesFunction · 0.92
TestUserFromFunction · 0.92
TestExtractFunction · 0.92

Calls 1

CloseMethod · 0.80

Tested by 7

TestPushImageFunction · 0.74
setupInMemoryRegistryFunction · 0.74
TestCompileWithFeaturesFunction · 0.74
TestUserFromFunction · 0.74
TestExtractFunction · 0.74