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

     1  package push
     2  
     3  import (
     4  	"io/ioutil"
     5  	"os"
     6  
     7  	"code.cloudfoundry.org/cli/integration/helpers"
     8  
     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("pushing a path with the -p flag", func() {
    16  	var (
    17  		appName string
    18  	)
    19  
    20  	BeforeEach(func() {
    21  		appName = helpers.NewAppName()
    22  	})
    23  
    24  	Context("pushing a directory", func() {
    25  		When("the directory contains files", func() {
    26  			It("pushes the app from the directory", func() {
    27  				helpers.WithHelloWorldApp(func(appDir string) {
    28  					session := helpers.CF(PushCommandName, appName, "-p", appDir)
    29  
    30  					Eventually(session).Should(Say(`Getting app info\.\.\.`))
    31  					Eventually(session).Should(Say(`Creating app with these attributes\.\.\.`))
    32  					Eventually(session).Should(helpers.SayPath(`path:\s+(\/private)?%s`, appDir))
    33  					Eventually(session).Should(Say("routes:"))
    34  					Eventually(session).Should(Say(`Mapping routes\.\.\.`))
    35  					Eventually(session).Should(Say(`Comparing local files to remote cache\.\.\.`))
    36  					Eventually(session).Should(Say(`Packaging files to upload\.\.\.`))
    37  					Eventually(session).Should(Say(`Uploading files\.\.\.`))
    38  					Eventually(session).Should(Say(`Waiting for API to complete processing files\.\.\.`))
    39  					Eventually(session).Should(Say(`Staging app and tracing logs\.\.\.`))
    40  					Eventually(session).Should(Say(`name:\s+%s`, appName))
    41  
    42  					Eventually(session).Should(Exit(0))
    43  				})
    44  			})
    45  		})
    46  
    47  		When("the directory is empty", func() {
    48  			var emptyDir string
    49  
    50  			BeforeEach(func() {
    51  				var err error
    52  				emptyDir, err = ioutil.TempDir("", "integration-push-path-empty")
    53  				Expect(err).ToNot(HaveOccurred())
    54  			})
    55  
    56  			AfterEach(func() {
    57  				Expect(os.RemoveAll(emptyDir)).ToNot(HaveOccurred())
    58  			})
    59  
    60  			It("returns an error", func() {
    61  				session := helpers.CF(PushCommandName, appName, "-p", emptyDir)
    62  				Eventually(session.Err).Should(helpers.SayPath("No app files found in '(/private)?%s'", emptyDir))
    63  				Eventually(session).Should(Exit(1))
    64  			})
    65  		})
    66  	})
    67  
    68  	Context("pushing a zip file", func() {
    69  		var archive string
    70  
    71  		BeforeEach(func() {
    72  			helpers.WithHelloWorldApp(func(appDir string) {
    73  				tmpfile, err := ioutil.TempFile("", "push-archive-integration")
    74  				Expect(err).ToNot(HaveOccurred())
    75  				archive = tmpfile.Name()
    76  				Expect(tmpfile.Close()).ToNot(HaveOccurred())
    77  
    78  				err = helpers.Zipit(appDir, archive, "")
    79  				Expect(err).ToNot(HaveOccurred())
    80  			})
    81  		})
    82  
    83  		AfterEach(func() {
    84  			Expect(os.RemoveAll(archive)).ToNot(HaveOccurred())
    85  		})
    86  
    87  		It("pushes the app from the zip file", func() {
    88  			session := helpers.CF(PushCommandName, appName, "-p", archive)
    89  
    90  			Eventually(session).Should(Say(`Getting app info\.\.\.`))
    91  			Eventually(session).Should(Say(`Creating app with these attributes\.\.\.`))
    92  			Eventually(session).Should(helpers.SayPath(`path:\s+(\/private)?%s`, archive))
    93  			Eventually(session).Should(Say("routes:"))
    94  			Eventually(session).Should(Say(`Mapping routes\.\.\.`))
    95  			Eventually(session).Should(Say(`Comparing local files to remote cache\.\.\.`))
    96  			Eventually(session).Should(Say(`Packaging files to upload\.\.\.`))
    97  			Eventually(session).Should(Say(`Uploading files\.\.\.`))
    98  			Eventually(session).Should(Say(`Waiting for API to complete processing files\.\.\.`))
    99  			Eventually(session).Should(Say(`Staging app and tracing logs\.\.\.`))
   100  			Eventually(session).Should(Say(`name:\s+%s`, appName))
   101  
   102  			Eventually(session).Should(Exit(0))
   103  		})
   104  	})
   105  })