forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_test.go
45 lines (39 loc) · 1.25 KB
/
docker_test.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
package flag_test
import (
. "code.cloudfoundry.org/cli/command/flag"
flags "github.com/jessevdk/go-flags"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Docker", func() {
var docker DockerImage
Describe("UnmarshalFlag", func() {
BeforeEach(func() {
docker = DockerImage{}
})
When("the docker image URL is a valid user/repo:tag URL", func() {
It("set the path and does not return an error", func() {
err := docker.UnmarshalFlag("user/repo:tag")
Expect(err).ToNot(HaveOccurred())
Expect(docker.Path).To(Equal("user/repo:tag"))
})
})
When("the docker image URL is an HTTP URL ", func() {
It("set the path and does not return an error", func() {
err := docker.UnmarshalFlag("registry.example.com:5000/user/repository/tag")
Expect(err).ToNot(HaveOccurred())
Expect(docker.Path).To(Equal("registry.example.com:5000/user/repository/tag"))
})
})
When("the docker image URL is invalid", func() {
It("returns an error", func() {
err := docker.UnmarshalFlag("AAAAAA")
Expect(err).To(MatchError(&flags.Error{
Type: flags.ErrRequired,
Message: "invalid docker reference: repository name must be lowercase",
}))
Expect(docker.Path).To(BeEmpty())
})
})
})
})