github.com/sleungcy-sap/cli@v7.1.0+incompatible/command/flag/docker_test.go (about) 1 package flag_test 2 3 import ( 4 . "code.cloudfoundry.org/cli/command/flag" 5 flags "github.com/jessevdk/go-flags" 6 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/gomega" 8 ) 9 10 var _ = Describe("Docker", func() { 11 var docker DockerImage 12 13 Describe("UnmarshalFlag", func() { 14 BeforeEach(func() { 15 docker = DockerImage{} 16 }) 17 18 When("the docker image URL is a valid user/repo:tag URL", func() { 19 It("set the path and does not return an error", func() { 20 err := docker.UnmarshalFlag("user/repo:tag") 21 Expect(err).ToNot(HaveOccurred()) 22 Expect(docker.Path).To(Equal("user/repo:tag")) 23 }) 24 }) 25 26 When("the docker image URL is an HTTP URL ", func() { 27 It("set the path and does not return an error", func() { 28 err := docker.UnmarshalFlag("registry.example.com:5000/user/repository/tag") 29 Expect(err).ToNot(HaveOccurred()) 30 Expect(docker.Path).To(Equal("registry.example.com:5000/user/repository/tag")) 31 }) 32 }) 33 34 When("the docker image URL is invalid", func() { 35 It("returns an error", func() { 36 err := docker.UnmarshalFlag("AAAAAA") 37 Expect(err).To(MatchError(&flags.Error{ 38 Type: flags.ErrRequired, 39 Message: "invalid docker reference: repository name must be lowercase", 40 })) 41 Expect(docker.Path).To(BeEmpty()) 42 }) 43 }) 44 }) 45 })