(t *testing.T)
| 302 | } |
| 303 | |
| 304 | func 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 | |
| 335 | func TestBuiltinDefaultLookasideStorageDir(t *testing.T) { |
| 336 | base := builtinDefaultLookasideStorageDir(0) |
nothing calls this directly
no test coverage detected
searching dependent graphs…