MCPcopy Create free account
hub / github.com/containers/image / TestLookasideStorageURL

Function TestLookasideStorageURL

docker/registries_d_test.go:304–333  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

302}
303
304func TestLookasideStorageURL(t *testing.T) {
305 const mdInput = "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
306 const mdMapped = "sha256=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
307
308 for _, c := range []struct {
309 base string
310 index int
311 expected string
312 }{
313 {"file:///tmp", 0, "file:///tmp@" + mdMapped + "/signature-1"},
314 {"file:///tmp", 1, "file:///tmp@" + mdMapped + "/signature-2"},
315 {"https://localhost:5555/root", 0, "https://localhost:5555/root@" + mdMapped + "/signature-1"},
316 {"https://localhost:5555/root", 1, "https://localhost:5555/root@" + mdMapped + "/signature-2"},
317 {"http://localhost:5555/root", 0, "http://localhost:5555/root@" + mdMapped + "/signature-1"},
318 {"http://localhost:5555/root", 1, "http://localhost:5555/root@" + mdMapped + "/signature-2"},
319 } {
320 baseURL, err := url.Parse(c.base)
321 require.NoError(t, err)
322 expectedURL, err := url.Parse(c.expected)
323 require.NoError(t, err)
324 res, err := lookasideStorageURL(baseURL, mdInput, c.index)
325 require.NoError(t, err)
326 assert.Equal(t, expectedURL, res, c.expected)
327 }
328
329 baseURL, err := url.Parse("file:///tmp")
330 require.NoError(t, err)
331 _, err = lookasideStorageURL(baseURL, digest.Digest("sha256:../hello"), 0)
332 assert.Error(t, err)
333}
334
335func TestBuiltinDefaultLookasideStorageDir(t *testing.T) {
336 base := builtinDefaultLookasideStorageDir(0)

Callers

nothing calls this directly

Calls 3

lookasideStorageURLFunction · 0.85
DigestMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…