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