Files
kairos-sdk/versioneer/container_name_test.go
Dimitris Karakasilis a8707c113a 1999 list releases (#61)
* Add registry and org to the os-release file

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Extract the software version prefix to a field

and make sure everything still works.
Also implement NoPrereleases method to filter out Kairos pre-releases

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Store RegistryAndOrg on the TagList

to be used in the new PrintImages method that prints full image URLs

This method will be used in the "kairos-agent upgrade list-releases" command

Also fix some relic softarePrefix arguments (Artifact now has that info)

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Implement sorting in a semver manner

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

* Implement FullImages method that returns the tags as full images

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>

---------

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2023-12-08 14:01:57 +02:00

65 lines
1.6 KiB
Go

package versioneer_test
import (
"github.com/kairos-io/kairos-sdk/versioneer"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("ContainerName", func() {
var artifact versioneer.Artifact
var expectedName string
var registryAndOrg string
BeforeEach(func() {
artifact = versioneer.Artifact{
Flavor: "opensuse",
FlavorRelease: "leap-15.5",
Variant: "standard",
Model: "generic",
Arch: "amd64",
Version: "v2.4.2",
SoftwareVersion: "v1.26.9+k3s1",
SoftwareVersionPrefix: "k3s",
}
registryAndOrg = "quay.io/kairos"
})
When("artifact is valid", func() {
When("SoftwareVersion is empty", func() {
BeforeEach(func() {
artifact.SoftwareVersion = ""
expectedName = "quay.io/kairos/opensuse:leap-15.5-standard-amd64-generic-v2.4.2"
})
It("returns the name", func() {
name, err := artifact.ContainerName(registryAndOrg)
Expect(err).ToNot(HaveOccurred())
Expect(name).To(Equal(expectedName))
})
})
When("SoftwareVersion is not empty", func() {
BeforeEach(func() {
expectedName = "quay.io/kairos/opensuse:leap-15.5-standard-amd64-generic-v2.4.2-k3sv1.26.9-k3s1"
})
It("returns the name", func() {
name, err := artifact.ContainerName(registryAndOrg)
Expect(err).ToNot(HaveOccurred())
Expect(name).To(Equal(expectedName))
})
})
})
When("artifact is invalid", func() {
BeforeEach(func() {
artifact.Flavor = ""
})
It("returns an error", func() {
_, err := artifact.ContainerName(registryAndOrg)
Expect(err).To(MatchError("Flavor is empty"))
})
})
})