github.com/ablease/cli@v6.37.1-0.20180613014814-3adbb7d7fb19+incompatible/integration/push/path_only_routing_test.go (about) 1 package push 2 3 import ( 4 "fmt" 5 "strings" 6 7 "code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" 8 "code.cloudfoundry.org/cli/integration/helpers" 9 10 . "github.com/onsi/ginkgo" 11 . "github.com/onsi/gomega" 12 . "github.com/onsi/gomega/gbytes" 13 . "github.com/onsi/gomega/gexec" 14 ) 15 16 var _ = Describe("push with route path", func() { 17 var ( 18 appName string 19 route string 20 ) 21 22 BeforeEach(func() { 23 appName = helpers.NewAppName() 24 }) 25 26 Context("when the default domain is a HTTP domain", func() { 27 Context("when the route path is provided", func() { 28 var routePath string 29 30 BeforeEach(func() { 31 routePath = "some-path" 32 route = fmt.Sprintf("%s.%s/%s", strings.ToLower(appName), helpers.DefaultSharedDomain(), routePath) 33 }) 34 35 Context("when the default route with path does not exist", func() { 36 It("creates and maps the route", func() { 37 helpers.WithHelloWorldApp(func(dir string) { 38 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--route-path", routePath, "--no-start") 39 Eventually(session).Should(Say("routes:")) 40 Eventually(session).Should(Say("(?i)\\+\\s+%s", route)) 41 Eventually(session).Should(Exit(0)) 42 }) 43 44 session := helpers.CF("app", appName) 45 Eventually(session).Should(Say("name:\\s+%s", appName)) 46 Eventually(session).Should(Say("routes:\\s+%s", route)) 47 Eventually(session).Should(Exit(0)) 48 }) 49 }) 50 51 Context("the default route with path exists and is unmapped", func() { 52 BeforeEach(func() { 53 Eventually(helpers.CF("create-route", space, helpers.DefaultSharedDomain(), "-n", strings.ToLower(appName), "--path", routePath)).Should(Exit(0)) 54 }) 55 56 It("maps the route with the provided path", func() { 57 helpers.WithHelloWorldApp(func(dir string) { 58 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--route-path", routePath, "--no-start") 59 Eventually(session).Should(Say("routes:")) 60 Eventually(session).Should(Say("(?i)\\+\\s+%s", route)) 61 Eventually(session).Should(Exit(0)) 62 }) 63 64 session := helpers.CF("app", appName) 65 Eventually(session).Should(Say("name:\\s+%s", appName)) 66 Eventually(session).Should(Say("routes:\\s+%s", route)) 67 Eventually(session).Should(Exit(0)) 68 }) 69 }) 70 71 Context("when the default route with path exists and is mapped to the application", func() { 72 BeforeEach(func() { 73 helpers.WithHelloWorldApp(func(dir string) { 74 Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--route-path", routePath, "--no-start")).Should(Exit(0)) 75 }) 76 }) 77 78 It("does nothing", func() { 79 helpers.WithHelloWorldApp(func(dir string) { 80 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--route-path", routePath, "--no-start") 81 Eventually(session).Should(Say("routes:")) 82 Eventually(session).Should(Say("(?i)\\s+%s", route)) 83 Eventually(session).Should(Exit(0)) 84 }) 85 86 session := helpers.CF("app", appName) 87 Eventually(session).Should(Say("name:\\s+%s", appName)) 88 Eventually(session).Should(Say("routes:\\s+%s", route)) 89 Eventually(session).Should(Exit(0)) 90 }) 91 }) 92 }) 93 94 Context("when using a tcp domain", func() { 95 var ( 96 domain helpers.Domain 97 domainName string 98 ) 99 100 BeforeEach(func() { 101 helpers.SkipIfVersionLessThan(ccversion.MinVersionRoutingV3) 102 103 domainName = helpers.DomainName() 104 domain = helpers.NewDomain(organization, domainName) 105 domain.CreateWithRouterGroup(helpers.FindOrCreateTCPRouterGroup(GinkgoParallelNode())) 106 }) 107 108 AfterEach(func() { 109 domain.DeleteShared() 110 }) 111 112 It("returns an error", func() { 113 session := helpers.CF(PushCommandName, appName, "--route-path", "/potatoes", "-d", domainName, "--no-start") 114 Eventually(session.Err).Should(Say("The route is invalid: a route path cannot be used with a TCP domain.")) 115 Eventually(session).Should(Exit(1)) 116 }) 117 }) 118 }) 119 })