Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions schema/manifest_backwards_compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ func convertFormats(input string) string {

func TestBackwardsCompatibilityManifestList(t *testing.T) {
for i, tt := range []struct {
manifest string
manifestlist string
digest string
fail bool
}{
{
digest: "sha256:219f4b61132fe9d09b0ec5c15517be2ca712e4744b0e0cc3be71295b35b2a467",
manifest: `{
manifestlist: `{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"manifests": [
Expand Down Expand Up @@ -110,14 +110,14 @@ func TestBackwardsCompatibilityManifestList(t *testing.T) {
fail: false,
},
} {
sum := sha256.Sum256([]byte(tt.manifest))
sum := sha256.Sum256([]byte(tt.manifestlist))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're in here, let's start using the digest package to perform these kinds of operations.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The digest open is manifeslist, so I think there is nothing wrong with the use of manifestlist here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not what I said. I meant that if you're in the process of cleaning up, it would be better to use the go-digest package.

I've filed #513 to take care this, so don't worry about it.

got := fmt.Sprintf("sha256:%s", hex.EncodeToString(sum[:]))
if tt.digest != got {
t.Errorf("test %d: expected digest %s but got %s", i, tt.digest, got)
}

manifest := convertFormats(tt.manifest)
r := strings.NewReader(manifest)
manifestlist := convertFormats(tt.manifestlist)
r := strings.NewReader(manifestlist)
err := schema.MediaTypeManifestList.Validate(r)

if got := err != nil; tt.fail != got {
Expand Down