github.com/sleungcy-sap/cli@v7.1.0+incompatible/command/flag/route_path_test.go (about) 1 package flag_test 2 3 import ( 4 . "code.cloudfoundry.org/cli/command/flag" 5 . "github.com/onsi/ginkgo" 6 . "github.com/onsi/gomega" 7 ) 8 9 var _ = Describe("V7RoutePath", func() { 10 var routePath V7RoutePath 11 12 Describe("UnmarshalFlag", func() { 13 BeforeEach(func() { 14 routePath = V7RoutePath{} 15 }) 16 17 When("passed a path beginning with a slash", func() { 18 It("sets the path", func() { 19 err := routePath.UnmarshalFlag("/banana") 20 Expect(err).ToNot(HaveOccurred()) 21 Expect(routePath.Path).To(Equal("/banana")) 22 }) 23 }) 24 25 When("passed a path that doesn't begin with a slash", func() { 26 It("prepends the path with a slash and sets it", func() { 27 err := routePath.UnmarshalFlag("banana") 28 Expect(err).ToNot(HaveOccurred()) 29 Expect(routePath.Path).To(Equal("/banana")) 30 }) 31 }) 32 33 When("passed an empty string", func() { 34 It("leaves the string as empty", func() { 35 err := routePath.UnmarshalFlag("") 36 Expect(err).ToNot(HaveOccurred()) 37 Expect(routePath.Path).To(Equal("")) 38 }) 39 }) 40 }) 41 })