-
Notifications
You must be signed in to change notification settings - Fork 11
/
public_registry.go
73 lines (58 loc) · 1.99 KB
/
public_registry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package checkers
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/agoda-com/samsahai/internal/samsahai/checker/publicregistry"
)
var _ = Describe("public registry checker [e2e]", func() {
var checker = publicregistry.New()
It("should returns non-empty name", func() {
Expect(checker.GetName()).NotTo(BeEmpty())
})
Specify("unsupported gcr registry", func() {
_, err := checker.GetVersion("gcr.io/google-samples/echo-go", "echo-go", ".*")
Expect(err).NotTo(BeNil())
})
Specify("invalid registry", func() {
_, err := checker.GetVersion("https://docker.io/phantomnat/curl", "echo-go", ".*")
Expect(err).NotTo(BeNil())
})
Specify("invalid pattern", func() {
_, err := checker.GetVersion("docker.io/phantomnat/curl", "echo-go", "[^0.+")
Expect(err).NotTo(BeNil())
})
Describe("docker.io [e2e]", func() {
It("should successfully get tag", func() {
var tag string
var err error
tag, err = checker.GetVersion("alpine:3.9", "alpine", "^3\\.9\\.\\d+")
Expect(err).To(BeNil())
Expect(tag).NotTo(BeEmpty())
tag, err = checker.GetVersion("docker.io/phantomnat/curl", "curl", "^0.+")
Expect(err).To(BeNil())
Expect(tag).NotTo(BeEmpty())
})
It("should not found the tag", func() {
tag, err := checker.GetVersion("phantomnat/curl", "curl", "^3\\.9\\.\\d+")
Expect(tag).To(Equal("^3\\.9\\.\\d+"))
Expect(err).NotTo(BeNil())
})
})
Describe("quay.io [e2e]", func() {
It("should successfully get tag", func() {
var tag string
var err error
tag, err = checker.GetVersion("quay.io/phantomnat/curl", "curl", "^0.+")
Expect(err).To(BeNil())
Expect(tag).NotTo(BeEmpty())
tag, err = checker.GetVersion("quay.io/mhart/alpine-node", "alpine-node", "^11.14.0")
Expect(err).To(BeNil())
Expect(tag).NotTo(BeEmpty())
})
It("should not found the tag", func() {
tag, err := checker.GetVersion("quay.io/phantomnat/curl", "curl", "^3\\.9\\.\\d+")
Expect(tag).To(Equal("^3\\.9\\.\\d+"))
Expect(err).NotTo(BeNil())
})
})
})