forked from TrueCloudLab/distribution
68944ea9cf
Previously, discussions were still ongoing about different storage layouts that could support various access models. This changeset removes a layer of indirection that was in place due to earlier designs. Effectively, this both associates a layer with a named repository and ensures that content cannot be accessed across repositories. It also moves to rely on tarsum as a true content-addressable identifier, removing a layer of indirection during blob resolution.
61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
package storage
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/docker/docker-registry/digest"
|
|
)
|
|
|
|
func TestPathMapper(t *testing.T) {
|
|
pm := &pathMapper{
|
|
root: "/pathmapper-test",
|
|
}
|
|
|
|
for _, testcase := range []struct {
|
|
spec pathSpec
|
|
expected string
|
|
err error
|
|
}{
|
|
{
|
|
spec: manifestPathSpec{
|
|
name: "foo/bar",
|
|
tag: "thetag",
|
|
},
|
|
expected: "/pathmapper-test/repositories/foo/bar/manifests/thetag",
|
|
},
|
|
{
|
|
spec: layerLinkPathSpec{
|
|
name: "foo/bar",
|
|
digest: digest.Digest("tarsum.v1+test:abcdef"),
|
|
},
|
|
expected: "/pathmapper-test/repositories/foo/bar/layers/tarsum/v1/test/ab/abcdef",
|
|
},
|
|
{
|
|
spec: blobPathSpec{
|
|
digest: digest.Digest("tarsum.dev+sha512:abcdefabcdefabcdef908909909"),
|
|
},
|
|
expected: "/pathmapper-test/blob/tarsum/dev/sha512/ab/abcdefabcdefabcdef908909909",
|
|
},
|
|
{
|
|
spec: blobPathSpec{
|
|
digest: digest.Digest("tarsum.v1+sha256:abcdefabcdefabcdef908909909"),
|
|
},
|
|
expected: "/pathmapper-test/blob/tarsum/v1/sha256/ab/abcdefabcdefabcdef908909909",
|
|
},
|
|
{
|
|
spec: blobPathSpec{
|
|
digest: digest.Digest("tarsum+sha256:abcdefabcdefabcdef908909909"),
|
|
},
|
|
expected: "/pathmapper-test/blob/tarsum/v0/sha256/ab/abcdefabcdefabcdef908909909",
|
|
},
|
|
} {
|
|
p, err := pm.path(testcase.spec)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if p != testcase.expected {
|
|
t.Fatalf("unexpected path generated: %q != %q", p, testcase.expected)
|
|
}
|
|
}
|
|
}
|