github.com/arunkumar7540/cli@v6.45.0+incompatible/integration/v7/push/combination_manifest_and_flag_test.go (about)

     1  package push
     2  
     3  import (
     4  	"io/ioutil"
     5  	"os"
     6  	"path/filepath"
     7  	"regexp"
     8  
     9  	"code.cloudfoundry.org/cli/integration/helpers"
    10  	. "github.com/onsi/ginkgo"
    11  	. "github.com/onsi/ginkgo/extensions/table"
    12  	. "github.com/onsi/gomega"
    13  	. "github.com/onsi/gomega/gbytes"
    14  	. "github.com/onsi/gomega/gexec"
    15  )
    16  
    17  var _ = Describe("push with a simple manifest and flags", func() {
    18  	When("the app is new", func() {
    19  		When("pushing multiple apps from the manifest", func() {
    20  			Context("manifest contains multiple apps and '--no-start' is provided", func() {
    21  				var appName1, appName2 string
    22  
    23  				BeforeEach(func() {
    24  					Skip("After #162558994 has been completed")
    25  					appName1 = helpers.NewAppName()
    26  					appName2 = helpers.NewAppName()
    27  				})
    28  
    29  				It("does not start the apps", func() {
    30  					helpers.WithHelloWorldApp(func(dir string) {
    31  						helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{
    32  							"applications": []map[string]string{
    33  								{"name": appName1},
    34  								{"name": appName2},
    35  							},
    36  						})
    37  
    38  						session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start")
    39  						Eventually(session).Should(Say(`Applying manifest\.\.\.`))
    40  						Eventually(session).Should(Say(`name:\s+%s`, appName1))
    41  						Eventually(session).Should(Say(`requested state:\s+stopped`))
    42  						Eventually(session).Should(Say(`name:\s+%s`, appName2))
    43  						Eventually(session).Should(Say(`requested state:\s+stopped`))
    44  						Eventually(session).Should(Exit(0))
    45  					})
    46  				})
    47  			})
    48  
    49  			Context("manifest contains multiple apps and a '-p' is provided", func() {
    50  				var tempDir string
    51  
    52  				BeforeEach(func() {
    53  					var err error
    54  					tempDir, err = ioutil.TempDir("", "combination-manifest-with-p")
    55  					Expect(err).ToNot(HaveOccurred())
    56  
    57  					helpers.WriteManifest(filepath.Join(tempDir, "manifest.yml"), map[string]interface{}{
    58  						"applications": []map[string]string{
    59  							{
    60  								"name": "name-1",
    61  							},
    62  							{
    63  								"name": "name-2",
    64  							},
    65  						},
    66  					})
    67  				})
    68  
    69  				AfterEach(func() {
    70  					Expect(os.RemoveAll(tempDir)).ToNot(HaveOccurred())
    71  				})
    72  
    73  				It("returns an error", func() {
    74  					helpers.WithHelloWorldApp(func(dir string) {
    75  						session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: tempDir}, PushCommandName, "-p", dir)
    76  						Eventually(session.Err).Should(Say(regexp.QuoteMeta("Incorrect Usage: Command line flags (except -f and --no-start) cannot be applied when pushing multiple apps from a manifest file.")))
    77  						Eventually(session).Should(Exit(1))
    78  					})
    79  				})
    80  			})
    81  
    82  			DescribeTable("errors when any flag (except for -f and --no-start) is specified",
    83  				func(flags ...string) {
    84  					helpers.WithHelloWorldApp(func(dir string) {
    85  						helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{
    86  							"applications": []map[string]string{
    87  								{"name": "some-app"},
    88  								{"name": "some-other-app"},
    89  							},
    90  						})
    91  
    92  						args := append([]string{PushCommandName}, flags...)
    93  						session := helpers.CustomCF(helpers.CFEnv{
    94  							WorkingDirectory: dir,
    95  							EnvVars:          map[string]string{"CF_DOCKER_PASSWORD": "some-password"},
    96  						}, args...)
    97  						Eventually(session.Err).Should(Say(regexp.QuoteMeta("Incorrect Usage: Command line flags (except -f and --no-start) cannot be applied when pushing multiple apps from a manifest file.")))
    98  						Eventually(session).Should(Exit(1))
    99  					})
   100  				},
   101  				Entry("buildpack", "-b", "somethin"),
   102  				Entry("disk", "-k", "100M"),
   103  				Entry("docker image", "-o", "something"),
   104  				Entry("docker image and username", "-o", "something", "--docker-username", "something"),
   105  				Entry("health check timeout", "-t", "10"),
   106  				Entry("health check type", "-u", "port"),
   107  				Entry("instances", "-i", "10"),
   108  				Entry("memory", "-m", "100M"),
   109  				Entry("no route", "--no-route"),
   110  				Entry("stack", "-s", "something"),
   111  			)
   112  		})
   113  	})
   114  })