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

     1  package push
     2  
     3  import (
     4  	"fmt"
     5  	"io/ioutil"
     6  	"os"
     7  	"path/filepath"
     8  
     9  	"code.cloudfoundry.org/cli/integration/helpers"
    10  	. "github.com/onsi/ginkgo"
    11  	. "github.com/onsi/gomega"
    12  	. "github.com/onsi/gomega/gbytes"
    13  	. "github.com/onsi/gomega/gexec"
    14  )
    15  
    16  var _ = Describe("push with a manifest and an app name", func() {
    17  	var (
    18  		appName                  string
    19  		randomHostName           string
    20  		tempDir                  string
    21  		pathToManifestForNoRoute string
    22  	)
    23  
    24  	BeforeEach(func() {
    25  		appName = helpers.NewAppName()
    26  		domainName := helpers.DefaultSharedDomain()
    27  		randomHostName = helpers.RandomName()
    28  
    29  		var err error
    30  		tempDir, err = ioutil.TempDir("", "no-route-flag-with-manifest-test")
    31  		Expect(err).ToNot(HaveOccurred())
    32  		pathToSetupManifest := filepath.Join(tempDir, "setup-manifest.yml")
    33  		helpers.WriteManifest(pathToSetupManifest, map[string]interface{}{
    34  			"applications": []map[string]interface{}{
    35  				{
    36  					"name": appName,
    37  					"routes": []map[string]string{
    38  						{"route": fmt.Sprintf("%s.%s", appName, domainName)},
    39  					},
    40  				},
    41  			},
    42  		})
    43  
    44  		helpers.WithHelloWorldApp(func(dir string) {
    45  			session := helpers.CustomCF(
    46  				helpers.CFEnv{WorkingDirectory: dir},
    47  				PushCommandName, appName,
    48  				"-f", pathToSetupManifest,
    49  				"--no-start")
    50  			Eventually(session).Should(Exit(0))
    51  		})
    52  
    53  		pathToManifestForNoRoute = filepath.Join(tempDir, "no-route-manifest.yml")
    54  		helpers.WriteManifest(pathToManifestForNoRoute, map[string]interface{}{
    55  			"applications": []map[string]interface{}{
    56  				{
    57  					"name": appName,
    58  					"routes": []map[string]string{
    59  						{"route": fmt.Sprintf("%s.%s", randomHostName, domainName)},
    60  					},
    61  				},
    62  			},
    63  		})
    64  	})
    65  
    66  	AfterEach(func() {
    67  		Expect(os.RemoveAll(tempDir)).ToNot(HaveOccurred())
    68  	})
    69  
    70  	It("pushes the app, doesnt map new routes, and removes old routes", func() {
    71  		helpers.WithHelloWorldApp(func(dir string) {
    72  			session := helpers.CustomCF(
    73  				helpers.CFEnv{WorkingDirectory: dir},
    74  				PushCommandName, appName,
    75  				"-f", pathToManifestForNoRoute,
    76  				"--no-start", "--no-route")
    77  			Eventually(session).Should(Exit(0))
    78  		})
    79  
    80  		session := helpers.CF("app", appName)
    81  		Eventually(session).Should(Say(`(?m)routes:\s+$`))
    82  		Eventually(session).Should(Exit(0))
    83  	})
    84  })