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

     1  package push
     2  
     3  import (
     4  	"io/ioutil"
     5  	"os"
     6  	"path/filepath"
     7  
     8  	"code.cloudfoundry.org/cli/integration/helpers"
     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("reading of the manifest based on location", func() {
    16  	var (
    17  		appName string
    18  	)
    19  
    20  	BeforeEach(func() {
    21  		appName = helpers.PrefixedRandomName("app")
    22  	})
    23  
    24  	When("the manifest exists in the current directory", func() {
    25  		When("the manifest has a .yml extension", func() {
    26  			It("detects manifests with a .yml suffix", func() {
    27  				helpers.WithHelloWorldApp(func(dir string) {
    28  					pathToManifest := filepath.Join(dir, "manifest.yml")
    29  					helpers.WriteManifest(pathToManifest, map[string]interface{}{
    30  						"applications": []map[string]interface{}{
    31  							{
    32  								"name": appName,
    33  							},
    34  						},
    35  					})
    36  					session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start")
    37  					Eventually(session).Should(Say("name:\\s+%s", appName))
    38  					Eventually(session).Should(Exit(0))
    39  				})
    40  			})
    41  		})
    42  
    43  		When("the manifest has a .yaml extension", func() {
    44  			It("detects manifests with a .yaml suffix", func() {
    45  				helpers.WithHelloWorldApp(func(dir string) {
    46  					pathToManifest := filepath.Join(dir, "manifest.yaml")
    47  					helpers.WriteManifest(pathToManifest, map[string]interface{}{
    48  						"applications": []map[string]interface{}{
    49  							{
    50  								"name": appName,
    51  							},
    52  						},
    53  					})
    54  					session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start")
    55  					Eventually(session).Should(Say("name:\\s+%s", appName))
    56  					Eventually(session).Should(Exit(0))
    57  				})
    58  			})
    59  		})
    60  	})
    61  
    62  	When("the manifest exists in some other directory", func() {
    63  		var workingDir string
    64  
    65  		BeforeEach(func() {
    66  			var err error
    67  			workingDir, err = ioutil.TempDir("", "manifest-working-dir")
    68  			Expect(err).ToNot(HaveOccurred())
    69  		})
    70  
    71  		AfterEach(func() {
    72  			Expect(os.RemoveAll(workingDir)).ToNot(HaveOccurred())
    73  		})
    74  
    75  		When("the manifest has a .yml extension", func() {
    76  			BeforeEach(func() {
    77  				pathToManifest := filepath.Join(workingDir, "manifest.yml")
    78  				helpers.WriteManifest(pathToManifest, map[string]interface{}{
    79  					"applications": []map[string]interface{}{
    80  						{
    81  							"name": appName,
    82  						},
    83  					},
    84  				})
    85  			})
    86  
    87  			It("detects manifests with a .yml suffix", func() {
    88  				helpers.WithHelloWorldApp(func(dir string) {
    89  					session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "-f", workingDir, "--no-start")
    90  					Eventually(session).Should(Say("name:\\s+%s", appName))
    91  					Eventually(session).Should(Exit(0))
    92  				})
    93  			})
    94  		})
    95  
    96  		When("the manifest has a .yaml extension", func() {
    97  			BeforeEach(func() {
    98  				pathToManifest := filepath.Join(workingDir, "manifest.yaml")
    99  				helpers.WriteManifest(pathToManifest, map[string]interface{}{
   100  					"applications": []map[string]interface{}{
   101  						{
   102  							"name": appName,
   103  						},
   104  					},
   105  				})
   106  			})
   107  
   108  			It("detects manifests with a .yaml suffix", func() {
   109  				helpers.WithHelloWorldApp(func(dir string) {
   110  					session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "-f", workingDir, "--no-start")
   111  					Eventually(session).Should(Say("name:\\s+%s", appName))
   112  					Eventually(session).Should(Exit(0))
   113  				})
   114  			})
   115  		})
   116  	})
   117  })