github.com/ablease/cli@v6.37.1-0.20180613014814-3adbb7d7fb19+incompatible/integration/push/tcp_random_route_test.go (about)

     1  package push
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccversion"
     5  	"code.cloudfoundry.org/cli/integration/helpers"
     6  	. "github.com/onsi/ginkgo"
     7  	. "github.com/onsi/gomega"
     8  	. "github.com/onsi/gomega/gbytes"
     9  	. "github.com/onsi/gomega/gexec"
    10  )
    11  
    12  var _ = Describe("TCP random route", func() {
    13  	var (
    14  		appName string
    15  	)
    16  
    17  	BeforeEach(func() {
    18  		appName = "short-app-name" // used on purpose to fit route length requirement
    19  	})
    20  
    21  	Context("when passed the --random-route flag", func() {
    22  		Context("when also passed a tcp domain", func() {
    23  			var domain helpers.Domain
    24  
    25  			BeforeEach(func() {
    26  				helpers.SkipIfVersionLessThan(ccversion.MinVersionRoutingV3)
    27  
    28  				domainName := helpers.DomainName("tcp-domain")
    29  				domain = helpers.NewDomain(organization, domainName)
    30  				domain.CreateWithRouterGroup(helpers.FindOrCreateTCPRouterGroup(GinkgoParallelNode()))
    31  			})
    32  
    33  			AfterEach(func() {
    34  				domain.DeleteShared()
    35  			})
    36  
    37  			It("creates a new route with the provided domain", func() {
    38  				helpers.WithHelloWorldApp(func(dir string) {
    39  					session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--random-route", "-d", domain.Name, "--no-start")
    40  					Eventually(session).Should(Say("\\+\\s+%s:\\?\\?\\?\\?", domain.Name))
    41  					Eventually(session).Should(Exit(0))
    42  				})
    43  			})
    44  
    45  			Context("when the app already exists with a tcp route", func() {
    46  				BeforeEach(func() {
    47  					helpers.WithHelloWorldApp(func(dir string) {
    48  						Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--random-route", "-d", domain.Name, "--no-start")).Should(Exit(0))
    49  					})
    50  				})
    51  
    52  				It("does not create any new routes", func() {
    53  					helpers.WithHelloWorldApp(func(dir string) {
    54  						session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--random-route", "-d", domain.Name, "--no-start")
    55  						Consistently(session).ShouldNot(Say("\\+\\s+%s:", domain.Name))
    56  						Eventually(session).Should(Exit(0))
    57  					})
    58  				})
    59  			})
    60  		})
    61  	})
    62  })