github.com/wanddynosios/cli@v7.1.0+incompatible/integration/v6/push/domain_test.go (about)

     1  package push
     2  
     3  import (
     4  	"strings"
     5  
     6  	"code.cloudfoundry.org/cli/integration/helpers"
     7  
     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 different domain values", func() {
    15  	var (
    16  		appName    string
    17  		domainName string
    18  	)
    19  
    20  	BeforeEach(func() {
    21  		appName = helpers.NewAppName()
    22  		domainName = helpers.NewDomainName("http-domain")
    23  	})
    24  
    25  	When("the domain flag is not provided", func() {
    26  		It("creates a route with the first shared domain", func() {
    27  			helpers.WithHelloWorldApp(func(dir string) {
    28  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    29  					PushCommandName, appName, "--no-start",
    30  				)
    31  				Eventually(session).Should(Say(`\s+routes:\s+%s.%s`, strings.ToLower(appName), helpers.DefaultSharedDomain()))
    32  				Eventually(session).Should(Exit(0))
    33  			})
    34  		})
    35  	})
    36  
    37  	When("only the domain flag is provided", func() {
    38  		When("the domain does not exist", func() {
    39  			It("creates a route that has the specified domain", func() {
    40  				helpers.WithHelloWorldApp(func(dir string) {
    41  					session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    42  						PushCommandName, appName, "--no-start",
    43  						"-d", domainName,
    44  					)
    45  					Eventually(session.Err).Should(Say("Domain '%s' not found.", domainName))
    46  					Eventually(session).Should(Exit(1))
    47  				})
    48  			})
    49  		})
    50  
    51  		When("domain is an HTTP domain", func() {
    52  			var domain helpers.Domain
    53  
    54  			BeforeEach(func() {
    55  				domain = helpers.NewDomain(organization, domainName)
    56  				domain.Create()
    57  			})
    58  
    59  			AfterEach(func() {
    60  				domain.Delete()
    61  			})
    62  
    63  			It("creates a route that has the specified domain", func() {
    64  				helpers.WithHelloWorldApp(func(dir string) {
    65  					session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    66  						PushCommandName, appName, "--no-start",
    67  						"-d", domainName,
    68  					)
    69  					Eventually(session).Should(Say(`\s+routes:\s+%s.%s`, strings.ToLower(appName), domainName))
    70  					Eventually(session).Should(Exit(0))
    71  				})
    72  			})
    73  		})
    74  
    75  		When("domain is a TCP domain", func() {
    76  			var domain helpers.Domain
    77  
    78  			BeforeEach(func() {
    79  				domainName = helpers.NewDomainName("tcp-domain")
    80  				domain = helpers.NewDomain(organization, domainName)
    81  				domain.CreateWithRouterGroup(helpers.FindOrCreateTCPRouterGroup(GinkgoParallelNode()))
    82  			})
    83  
    84  			AfterEach(func() {
    85  				domain.DeleteShared()
    86  			})
    87  
    88  			It("creates a new route with the specified domain and a random port each time the app is pushed", func() {
    89  				helpers.WithHelloWorldApp(func(dir string) {
    90  					session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    91  						PushCommandName, appName, "--no-start",
    92  						"-d", domainName,
    93  					)
    94  					Eventually(session).Should(Say(`\+\s+%s:\?\?\?\?`, domainName))
    95  					Eventually(session).Should(Say(`\s+routes:\s+%s:\d+`, domainName))
    96  					// instead of checking that the port is different each time we push
    97  					// the same app, we check that the push does not fail
    98  					Eventually(session).Should(Exit(0))
    99  
   100  					session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
   101  						PushCommandName, appName,
   102  						"-d", domainName,
   103  					)
   104  					Eventually(session).Should(Say(`\+\s+%s:\?\?\?\?`, domainName))
   105  					Eventually(session).Should(Say(`\s+routes:\s+%s:\d+`, domainName))
   106  					Eventually(session).Should(Exit(0))
   107  				})
   108  			})
   109  		})
   110  	})
   111  })