github.com/loafoe/cli@v7.1.0+incompatible/integration/v6/push/droplet_test.go (about)

     1  package push
     2  
     3  import (
     4  	"fmt"
     5  	"io/ioutil"
     6  	"os"
     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("when a droplet is provided", func() {
    17  	var (
    18  		appName     string
    19  		dropletPath string
    20  	)
    21  
    22  	BeforeEach(func() {
    23  		appName = helpers.NewAppName()
    24  
    25  		helpers.WithHelloWorldApp(func(appDir string) {
    26  			tmpfile, err := ioutil.TempFile("", "dropletFile")
    27  			Expect(err).ToNot(HaveOccurred())
    28  			dropletPath = tmpfile.Name()
    29  			Expect(tmpfile.Close()).ToNot(HaveOccurred())
    30  
    31  			tempApp := helpers.NewAppName()
    32  			session := helpers.CF(PushCommandName, tempApp, "-b", "staticfile_buildpack")
    33  			Eventually(session).Should(Exit(0))
    34  
    35  			appGUID := helpers.AppGUID(tempApp)
    36  			Eventually(helpers.CF("curl", fmt.Sprintf("/v2/apps/%s/droplet/download", appGUID), "--output", dropletPath)).Should(Exit(0))
    37  			_, err = os.Stat(dropletPath)
    38  			Expect(err).ToNot(HaveOccurred())
    39  		})
    40  	})
    41  
    42  	AfterEach(func() {
    43  		Expect(os.RemoveAll(dropletPath)).ToNot(HaveOccurred())
    44  	})
    45  
    46  	When("the app does not exist", func() {
    47  		It("creates the app", func() {
    48  			session := helpers.CF(PushCommandName, appName, "--droplet", dropletPath)
    49  			Eventually(session).Should(Say(`Getting app info\.\.\.`))
    50  			Eventually(session).Should(Say(`Creating app with these attributes\.\.\.`))
    51  			Eventually(session).Should(Say(`\+\s+name:\s+%s`, appName))
    52  			Eventually(session).Should(Say(`Uploading droplet\.\.\.`))
    53  			Eventually(session).Should(Say(`Waiting for app to start\.\.\.`))
    54  			Eventually(session).Should(Say(`requested state:\s+started`))
    55  			Eventually(session).Should(Exit(0))
    56  
    57  			session = helpers.CF("app", appName)
    58  			Eventually(session).Should(Say(`name:\s+%s`, appName))
    59  			Eventually(session).Should(Exit(0))
    60  		})
    61  	})
    62  
    63  	When("the app exists", func() {
    64  		BeforeEach(func() {
    65  			helpers.WithHelloWorldApp(func(appDir string) {
    66  				Eventually(helpers.CF(PushCommandName, appName, "-p", appDir, "-b", "staticfile_buildpack")).Should(Exit(0))
    67  			})
    68  		})
    69  
    70  		It("updates the app", func() {
    71  			session := helpers.CF(PushCommandName, appName, "--droplet", dropletPath)
    72  			Eventually(session).Should(Say(`Updating app with these attributes\.\.\.`))
    73  			Eventually(session).Should(Say(`Uploading droplet\.\.\.`))
    74  			Eventually(session).Should(Exit(0))
    75  		})
    76  	})
    77  })