github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/integration/push/no_hostname_test.go (about)

     1  package push
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/integration/helpers"
     5  
     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("pushing with no-hostname", func() {
    13  	var (
    14  		appName    string
    15  		domainName string
    16  	)
    17  
    18  	BeforeEach(func() {
    19  		appName = helpers.NewAppName()
    20  		domainName = helpers.DomainName()
    21  	})
    22  
    23  	Context("when pushing with no manifest", func() {
    24  		Context("when using a private domain", func() {
    25  			var domain helpers.Domain
    26  
    27  			BeforeEach(func() {
    28  				domain = helpers.NewDomain(organization, domainName)
    29  				domain.Create()
    30  			})
    31  
    32  			AfterEach(func() {
    33  				domain.Delete()
    34  			})
    35  
    36  			It("creates a route with no hostname", func() {
    37  				helpers.WithHelloWorldApp(func(dir string) {
    38  					session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--no-hostname", "-d", domainName, "--no-start")
    39  					Eventually(session).Should(Say("\\+\\s+name:\\s+%s", appName))
    40  					Eventually(session).Should(Say("\\+\\s+%s", domainName))
    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("(?m)routes:\\s+%s", domainName))
    47  				Eventually(session).Should(Exit(0))
    48  			})
    49  		})
    50  
    51  		Context("when using a shared domain", func() {
    52  			Context("when using an HTTP domain", func() {
    53  				It("returns an invalid route error", func() {
    54  					helpers.WithHelloWorldApp(func(dir string) {
    55  						session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--no-hostname", "--no-start")
    56  						Eventually(session.Err).Should(Say("The route is invalid: a hostname is required for shared domains."))
    57  						Eventually(session).Should(Exit(1))
    58  					})
    59  				})
    60  			})
    61  
    62  			Context("when using a TCP domain", func() {
    63  				var domain helpers.Domain
    64  
    65  				BeforeEach(func() {
    66  					domain = helpers.NewDomain(organization, domainName)
    67  					domain.CreateWithRouterGroup(helpers.FindOrCreateTCPRouterGroup(GinkgoParallelNode()))
    68  				})
    69  
    70  				AfterEach(func() {
    71  					domain.DeleteShared()
    72  				})
    73  
    74  				It("creates a TCP route", func() {
    75  					helpers.WithHelloWorldApp(func(dir string) {
    76  						session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--no-hostname", "-d", domainName, "--no-start")
    77  						Eventually(session).Should(Say("\\+\\s+name:\\s+%s", appName))
    78  						Eventually(session).Should(Say("\\+\\s+%s:", domainName))
    79  						Eventually(session).Should(Exit(0))
    80  					})
    81  
    82  					session := helpers.CF("app", appName)
    83  					Eventually(session).Should(Say("name:\\s+%s", appName))
    84  					Eventually(session).Should(Say("(?m)routes:\\s+%s:\\d+", domainName))
    85  					Eventually(session).Should(Exit(0))
    86  				})
    87  			})
    88  		})
    89  	})
    90  })