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