github.com/loafoe/cli@v7.1.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+%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  				emptyDir = helpers.TempDirAbsolutePath("", "integration-push-path-empty")
    52  			})
    53  
    54  			AfterEach(func() {
    55  				Expect(os.RemoveAll(emptyDir)).ToNot(HaveOccurred())
    56  			})
    57  
    58  			It("returns an error", func() {
    59  				session := helpers.CF(PushCommandName, appName, "-p", emptyDir)
    60  				Eventually(session.Err).Should(helpers.SayPath("No app files found in '%s'", emptyDir))
    61  				Eventually(session).Should(Exit(1))
    62  			})
    63  		})
    64  	})
    65  
    66  	Context("pushing a zip file", func() {
    67  		var archive string
    68  
    69  		BeforeEach(func() {
    70  			helpers.WithHelloWorldApp(func(appDir string) {
    71  				tmpfile, err := ioutil.TempFile("", "push-archive-integration")
    72  				Expect(err).ToNot(HaveOccurred())
    73  				archive = tmpfile.Name()
    74  				Expect(tmpfile.Close()).ToNot(HaveOccurred())
    75  
    76  				err = helpers.Zipit(appDir, archive, "")
    77  				Expect(err).ToNot(HaveOccurred())
    78  			})
    79  		})
    80  
    81  		AfterEach(func() {
    82  			Expect(os.RemoveAll(archive)).ToNot(HaveOccurred())
    83  		})
    84  
    85  		It("pushes the app from the zip file", func() {
    86  			session := helpers.CF(PushCommandName, appName, "-p", archive)
    87  
    88  			Eventually(session).Should(Say(`Getting app info\.\.\.`))
    89  			Eventually(session).Should(Say(`Creating app with these attributes\.\.\.`))
    90  			Eventually(session).Should(helpers.SayPath(`path:\s+(?:/private)?%s`, archive))
    91  			Eventually(session).Should(Say("routes:"))
    92  			Eventually(session).Should(Say(`Mapping routes\.\.\.`))
    93  			Eventually(session).Should(Say(`Comparing local files to remote cache\.\.\.`))
    94  			Eventually(session).Should(Say(`Packaging files to upload\.\.\.`))
    95  			Eventually(session).Should(Say(`Uploading files\.\.\.`))
    96  			Eventually(session).Should(Say(`Waiting for API to complete processing files\.\.\.`))
    97  			Eventually(session).Should(Say(`Staging app and tracing logs\.\.\.`))
    98  			Eventually(session).Should(Say(`name:\s+%s`, appName))
    99  
   100  			Eventually(session).Should(Exit(0))
   101  		})
   102  	})
   103  })