github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+incompatible/integration/push/hostname_only_routing_test.go (about) 1 package push 2 3 import ( 4 "fmt" 5 "net/http" 6 7 "code.cloudfoundry.org/cli/integration/helpers" 8 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/ginkgo/extensions/table" 11 . "github.com/onsi/gomega" 12 . "github.com/onsi/gomega/gbytes" 13 . "github.com/onsi/gomega/gexec" 14 ) 15 16 var _ = Describe("push with hostname", func() { 17 Context("when the default domain is a shared domain", func() { 18 DescribeTable("creates and binds the route as neccessary", 19 func(existingRoute bool, boundRoute bool, setup func(appName string, dir string) *Session) { 20 appName := helpers.NewAppName() 21 22 if existingRoute { 23 session := helpers.CF("create-route", space, defaultSharedDomain(), "-n", appName) 24 Eventually(session).Should(Exit(0)) 25 } 26 27 if boundRoute { 28 helpers.WithHelloWorldApp(func(dir string) { 29 // TODO: Add --no-start 30 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName) 31 Eventually(session).Should(Exit(0)) 32 }) 33 } 34 35 helpers.WithHelloWorldApp(func(dir string) { 36 session := setup(appName, dir) 37 38 Eventually(session).Should(Say("routes:")) 39 if existingRoute && boundRoute { 40 Eventually(session).Should(Say("(?i)%s.%s", appName, defaultSharedDomain())) 41 } else { 42 Eventually(session).Should(Say("(?i)\\+\\s+%s.%s", appName, defaultSharedDomain())) 43 } 44 Eventually(session).Should(Say("Mapping routes...")) 45 46 Eventually(session).Should(Exit(0)) 47 }) 48 49 resp, err := http.Get(fmt.Sprintf("http://%s.%s", appName, defaultSharedDomain())) 50 Expect(err).ToNot(HaveOccurred()) 51 Expect(resp.StatusCode).To(Equal(http.StatusOK)) 52 }, 53 54 Entry("when the hostname is provided via the appName and route does not exist", false, false, func(appName string, dir string) *Session { 55 // TODO: Add --no-start 56 // TODO: Add --path 57 return helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName) 58 }), 59 60 Entry("when the hostname is provided via the appName and the unbound route exists", true, false, func(appName string, dir string) *Session { 61 // TODO: Add --no-start 62 // TODO: Add --path 63 return helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName) 64 }), 65 66 Entry("when the hostname is provided via the appName and the bound route exists", true, true, func(appName string, dir string) *Session { 67 // TODO: Add --no-start 68 // TODO: Add --path 69 return helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName) 70 }), 71 ) 72 }) 73 })