2020-12-06 13:21:04 +01:00
|
|
|
package helpers
|
|
|
|
|
|
|
|
import (
|
2023-04-12 17:15:12 +02:00
|
|
|
"testing"
|
|
|
|
|
2020-12-06 13:21:04 +01:00
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestHelpers(t *testing.T) {
|
|
|
|
RegisterFailHandler(Fail)
|
|
|
|
RunSpecs(t, "Helper Suite")
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ = Describe("the helpers", func() {
|
2023-04-12 17:15:12 +02:00
|
|
|
Describe("GetRegistryAddress", func() {
|
|
|
|
It("should return error if passed empty string", func() {
|
|
|
|
_, err := GetRegistryAddress("")
|
|
|
|
Expect(err).To(HaveOccurred())
|
2020-12-06 13:21:04 +01:00
|
|
|
})
|
2023-04-12 17:15:12 +02:00
|
|
|
It("should return index.docker.io for image refs with no explicit registry", func() {
|
|
|
|
Expect(GetRegistryAddress("watchtower")).To(Equal("index.docker.io"))
|
2023-10-04 12:17:38 +02:00
|
|
|
Expect(GetRegistryAddress("nickfedor/watchtower")).To(Equal("index.docker.io"))
|
2023-04-12 17:15:12 +02:00
|
|
|
})
|
|
|
|
It("should return index.docker.io for image refs with docker.io domain", func() {
|
|
|
|
Expect(GetRegistryAddress("docker.io/watchtower")).To(Equal("index.docker.io"))
|
2023-10-04 12:17:38 +02:00
|
|
|
Expect(GetRegistryAddress("docker.io/nickfedor/watchtower")).To(Equal("index.docker.io"))
|
2023-04-12 17:15:12 +02:00
|
|
|
})
|
|
|
|
It("should return the host if passed an image name containing a local host", func() {
|
|
|
|
Expect(GetRegistryAddress("henk:80/watchtower")).To(Equal("henk:80"))
|
|
|
|
Expect(GetRegistryAddress("localhost/watchtower")).To(Equal("localhost"))
|
|
|
|
})
|
|
|
|
It("should return the server address if passed a fully qualified image name", func() {
|
2023-10-04 12:17:38 +02:00
|
|
|
Expect(GetRegistryAddress("github.com/nicholas-fedor/config")).To(Equal("github.com"))
|
2020-12-06 13:21:04 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|