containerd/images/oci/importer_test.go
Akihiro Suda 63401970c7 importer: refactor
- Use lease API (previoisly, GC was not supported)
- Refactored interfaces for ease of future Docker v1 importer support

For usage, please refer to `ctr images import --help`.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-12-05 12:48:32 +09:00

38 lines
1001 B
Go

package oci
import (
"testing"
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/stretchr/testify/assert"
)
func TestNormalizeImageRef(t *testing.T) {
imageBaseName := "foo/bar"
for _, test := range []struct {
input ocispec.Descriptor
expect string
}{
{
input: ocispec.Descriptor{
Digest: digest.Digest("sha256:e22e93af8657d43d7f204b93d69604aeacf273f71d2586288cde312808c0ec77"),
},
expect: "foo/bar@sha256:e22e93af8657d43d7f204b93d69604aeacf273f71d2586288cde312808c0ec77",
},
{
input: ocispec.Descriptor{
Digest: digest.Digest("sha256:e22e93af8657d43d7f204b93d69604aeacf273f71d2586288cde312808c0ec77"),
Annotations: map[string]string{
ocispec.AnnotationRefName: "latest",
},
},
expect: "foo/bar:latest", // no @digest for simplicity
},
} {
normalized, err := normalizeImageRef(imageBaseName, test.input)
assert.NoError(t, err)
assert.Equal(t, test.expect, normalized)
}
}