github.com/randomtask1155/cli@v6.41.1-0.20181227003417-a98eed78cbde+incompatible/integration/v6/push/path_test.go (about)

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