github.com/sleungcy-sap/cli@v7.1.0+incompatible/integration/v7/push/no_route_test.go (about)

     1  package push
     2  
     3  import (
     4  	"path/filepath"
     5  
     6  	"code.cloudfoundry.org/cli/integration/helpers"
     7  	. "github.com/onsi/ginkgo"
     8  	. "github.com/onsi/gomega"
     9  	. "github.com/onsi/gomega/gbytes"
    10  	. "github.com/onsi/gomega/gexec"
    11  )
    12  
    13  var _ = Describe("no-route", func() {
    14  
    15  	var (
    16  		appName string
    17  	)
    18  
    19  	BeforeEach(func() {
    20  		appName = helpers.PrefixedRandomName("app")
    21  	})
    22  
    23  	When("the --no-route flag is set", func() {
    24  		It("does not map any routes to the app", func() {
    25  			helpers.WithHelloWorldApp(func(appDir string) {
    26  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, PushCommandName, appName, "--no-start", "--no-route")
    27  				Consistently(session).ShouldNot(Say(`Mapping routes\.\.\.`))
    28  				Eventually(session).Should(Say(`name:\s+%s`, appName))
    29  				Eventually(session).Should(Say(`requested state:\s+stopped`))
    30  				Eventually(session).Should(Say(`(?m)routes:\s+\n`))
    31  				Eventually(session).Should(Exit(0))
    32  			})
    33  		})
    34  
    35  		It("unmaps currently mapped routes", func() {
    36  			helpers.WithHelloWorldApp(func(appDir string) {
    37  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, PushCommandName, appName, "--no-start")
    38  				Eventually(session).Should(Exit(0))
    39  
    40  				session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, PushCommandName, appName, "--no-start", "--no-route")
    41  				Consistently(session).ShouldNot(Say(`Mapping routes\.\.\.`))
    42  				Eventually(session).Should(Say(`name:\s+%s`, appName))
    43  				Eventually(session).Should(Say(`requested state:\s+stopped`))
    44  				Eventually(session).Should(Say(`(?m)routes:\s+\n`))
    45  				Eventually(session).Should(Exit(0))
    46  			})
    47  		})
    48  	})
    49  
    50  	When("the no-route is in the manifest", func() {
    51  		It("does not map any routes to the app", func() {
    52  			helpers.WithHelloWorldApp(func(appDir string) {
    53  				manifestPath := filepath.Join(appDir, "manifest.yml")
    54  				helpers.WriteManifest(manifestPath, map[string]interface{}{
    55  					"applications": []map[string]interface{}{
    56  						{
    57  							"name":     appName,
    58  							"no-route": true,
    59  						},
    60  					},
    61  				})
    62  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, PushCommandName, appName, "--no-start")
    63  				Consistently(session).ShouldNot(Say(`Mapping routes\.\.\.`))
    64  				Eventually(session).Should(Say(`name:\s+%s`, appName))
    65  				Eventually(session).Should(Say(`requested state:\s+stopped`))
    66  				Eventually(session).Should(Say(`(?m)routes:\s+\n`))
    67  				Eventually(session).Should(Exit(0))
    68  			})
    69  		})
    70  	})
    71  })