pkg/registry: improve logging, tests & (test) readability

This commit is contained in:
Reinier van der Leer 2023-01-22 17:51:45 +01:00
parent 905a38f24c
commit 6d64f81ad4
No known key found for this signature in database
GPG key ID: DBC4942A5C29D7FA
8 changed files with 90 additions and 76 deletions

View file

@ -18,15 +18,19 @@ var _ = Describe("the helpers", func() {
_, err := GetRegistryAddress("")
Expect(err).To(HaveOccurred())
})
It("should return index.docker.io if passed an image name with no explicit domain", func() {
It("should return index.docker.io for image refs with no explicit registry", func() {
Expect(GetRegistryAddress("watchtower")).To(Equal("index.docker.io"))
Expect(GetRegistryAddress("containrrr/watchtower")).To(Equal("index.docker.io"))
})
It("should return index.docker.io for image refs with docker.io domain", func() {
Expect(GetRegistryAddress("docker.io/watchtower")).To(Equal("index.docker.io"))
Expect(GetRegistryAddress("docker.io/containrrr/watchtower")).To(Equal("index.docker.io"))
})
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 name if passed a fully qualified image name", func() {
It("should return the server address if passed a fully qualified image name", func() {
Expect(GetRegistryAddress("github.com/containrrr/config")).To(Equal("github.com"))
})
})