github.com/sap/cf-mta-plugin@v2.6.3+incompatible/util/builders_test.go (about) 1 package util_test 2 3 import ( 4 "github.com/cloudfoundry-incubator/multiapps-cli-plugin/util" 5 . "github.com/onsi/ginkgo" 6 . "github.com/onsi/gomega" 7 ) 8 9 var _ = Describe("UriBuilderTest", func() { 10 Describe("BuildUriTest", func() { 11 const hostName = "test-host" 12 const scheme = "test-scheme" 13 const path = "test-path" 14 15 Context("no scheme and host are provided", func() { 16 It("should return an error", func() { 17 uriBuilder := util.NewUriBuilder().SetPath(path) 18 _, err := uriBuilder.Build() 19 20 Expect(err).Should(MatchError("The host or scheme could not be empty")) 21 }) 22 }) 23 Context("when scheme and path are provided", func() { 24 It("should return an error", func() { 25 uriBuilder := util.NewUriBuilder().SetScheme(scheme).SetPath(path) 26 _, err := uriBuilder.Build() 27 28 Expect(err).Should(MatchError("The host or scheme could not be empty")) 29 }) 30 }) 31 Context("when scheme, host and path are provided", func() { 32 It("should the built uri", func() { 33 uriBuilder := util.NewUriBuilder().SetHost(hostName).SetScheme(scheme).SetPath(path) 34 uri, err := uriBuilder.Build() 35 36 Expect(uri).To(Equal("test-scheme://test-host/test-path")) 37 Expect(err).To(BeNil()) 38 }) 39 }) 40 41 }) 42 })