github.com/arunkumar7540/cli@v6.45.0+incompatible/integration/v7/push/manifest_with_app_name_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  		secondName     string
    20  		tempDir        string
    21  		pathToManifest string
    22  	)
    23  
    24  	BeforeEach(func() {
    25  		appName = helpers.NewAppName()
    26  		secondName = helpers.NewAppName()
    27  		var err error
    28  		tempDir, err = ioutil.TempDir("", "simple-manifest-test")
    29  		Expect(err).ToNot(HaveOccurred())
    30  		pathToManifest = filepath.Join(tempDir, "manifest.yml")
    31  		helpers.WriteManifest(pathToManifest, map[string]interface{}{
    32  			"applications": []map[string]interface{}{
    33  				{
    34  					"name": appName,
    35  					"env": map[string]interface{}{
    36  						"key1": "val1",
    37  						"key4": false,
    38  					},
    39  				},
    40  				{
    41  					"name": secondName,
    42  					"env": map[string]interface{}{
    43  						"key1": "val1",
    44  						"key4": false,
    45  					},
    46  				},
    47  			},
    48  		})
    49  	})
    50  
    51  	AfterEach(func() {
    52  		Expect(os.RemoveAll(tempDir)).ToNot(HaveOccurred())
    53  	})
    54  
    55  	It("pushes only the specified app", func() {
    56  		helpers.WithHelloWorldApp(func(dir string) {
    57  			session := helpers.CustomCF(
    58  				helpers.CFEnv{WorkingDirectory: dir},
    59  				PushCommandName, appName,
    60  				"-f", pathToManifest,
    61  				"--no-start")
    62  			Eventually(session).Should(Exit(0))
    63  		})
    64  
    65  		session := helpers.CF("env", appName)
    66  		Eventually(session).Should(Say(`key1:\s+val1`))
    67  		Eventually(session).Should(Say(`key4:\s+false`))
    68  		Eventually(session).Should(Exit(0))
    69  
    70  		session = helpers.CF("env", secondName)
    71  		Eventually(session.Err).Should(Say(fmt.Sprintf("App '%s' not found", secondName)))
    72  		Eventually(session).Should(Exit(1))
    73  	})
    74  
    75  	When("tha app name is not in the manifest", func() {
    76  		It("errors", func() {
    77  			helpers.WithHelloWorldApp(func(dir string) {
    78  				session := helpers.CustomCF(
    79  					helpers.CFEnv{WorkingDirectory: dir},
    80  					PushCommandName, "bad-app",
    81  					"-f", pathToManifest,
    82  					"--no-start")
    83  				Eventually(session.Err).Should(Say(`Could not find app named 'bad-app' in manifest`))
    84  				Eventually(session).Should(Exit(1))
    85  			})
    86  
    87  		})
    88  	})
    89  
    90  })