-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix version info for OCI refs (#1078)
<!-- markdownlint-disable MD041 --> #### What this PR does / why we need it PR #1033 introduced a split of the OCI version info from the repository part. The method `Version` checks the inverted condition for an existing version inf. #### Which issue(s) this PR fixes <!-- Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. --> --------- Co-authored-by: Jakob Möller <contact@jakob-moeller.com>
- Loading branch information
1 parent
782970c
commit a1890c2
Showing
6 changed files
with
109 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package ociutils_test | ||
|
||
import ( | ||
. "github.com/mandelsoft/goutils/testutils" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/opencontainers/go-digest" | ||
"ocm.software/ocm/api/oci/ociutils" | ||
"ocm.software/ocm/api/oci/testhelper" | ||
) | ||
|
||
var _ = Describe("Ref Test Environment", func() { | ||
dig := "sha256:" + testhelper.H_OCIARCHMANIFEST1 | ||
|
||
type expect struct { | ||
yaml string | ||
versionSpec string | ||
isVersion bool | ||
version string | ||
isTag bool | ||
tag string | ||
isDigested bool | ||
digest string | ||
} | ||
|
||
DescribeTable("parsing", func(src string, e expect) { | ||
v := Must(ociutils.ParseVersion(src)) | ||
Expect(v).NotTo(BeNil()) | ||
Expect(v).To(YAMLEqual(e.yaml)) | ||
Expect(v.VersionSpec()).To(Equal(e.versionSpec)) | ||
Expect(v.IsVersion()).To(Equal(e.isVersion)) | ||
Expect(v.Version()).To(Equal(e.version)) | ||
Expect(v.IsTagged()).To(Equal(e.isTag)) | ||
Expect(v.GetTag()).To(Equal(e.tag)) | ||
Expect(v.IsDigested()).To(Equal(e.isDigested)) | ||
Expect(v.GetDigest()).To(Equal(digest.Digest(e.digest))) | ||
}, | ||
Entry("empty", "", expect{ | ||
yaml: "{}", | ||
versionSpec: "latest", | ||
version: "latest", | ||
}), | ||
Entry("tag", "tag", expect{ | ||
yaml: "{\"tag\":\"tag\"}", | ||
versionSpec: "tag", | ||
isVersion: true, | ||
version: "tag", | ||
isTag: true, | ||
tag: "tag", | ||
}), | ||
Entry("digest", "@"+dig, expect{ | ||
yaml: "{\"digest\":\"" + dig + "\"}", | ||
versionSpec: "@" + dig, | ||
isVersion: true, | ||
version: "@" + dig, | ||
isDigested: true, | ||
digest: dig, | ||
}), | ||
Entry("tag@digest", "tag@"+dig, expect{ | ||
yaml: "{\"tag\":\"tag\",\"digest\":\"" + dig + "\"}", | ||
versionSpec: "tag@" + dig, | ||
isVersion: true, | ||
version: "@" + dig, | ||
isTag: true, | ||
tag: "tag", | ||
isDigested: true, | ||
digest: dig, | ||
}), | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ociutils_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestConfig(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "OCI Utils Test Suite") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters