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

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