github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/integration/push/buildpack_test.go (about)

     1  package push
     2  
     3  import (
     4  	"fmt"
     5  	"io/ioutil"
     6  	"math/rand"
     7  	"path/filepath"
     8  
     9  	"code.cloudfoundry.org/cli/integration/helpers"
    10  
    11  	. "github.com/onsi/ginkgo"
    12  	. "github.com/onsi/gomega"
    13  	. "github.com/onsi/gomega/gbytes"
    14  	. "github.com/onsi/gomega/gexec"
    15  )
    16  
    17  var _ = Describe("push with different buildpack values", func() {
    18  	var (
    19  		appName string
    20  	)
    21  
    22  	BeforeEach(func() {
    23  		appName = helpers.NewAppName()
    24  	})
    25  
    26  	Context("when the buildpack flag is provided", func() {
    27  		It("sets that buildpack correctly for the pushed app", func() {
    28  			helpers.WithProcfileApp(func(dir string) {
    29  				tempfile := filepath.Join(dir, "index.html")
    30  				err := ioutil.WriteFile(tempfile, []byte(fmt.Sprintf("hello world %d", rand.Int())), 0666)
    31  				Expect(err).ToNot(HaveOccurred())
    32  
    33  				By("pushing a ruby app with a static buildpack sets buildpack to static")
    34  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    35  					PushCommandName, appName,
    36  					"-b", "staticfile_buildpack",
    37  				)
    38  				Eventually(session).Should(Say("Staticfile Buildpack"))
    39  				Eventually(session).Should(Exit(0))
    40  
    41  				session = helpers.CF("app", appName)
    42  				Eventually(session).Should(Say("buildpack:\\s+staticfile_buildpack"))
    43  				Eventually(session).Should(Exit(0))
    44  
    45  				By("pushing a ruby app with a null buildpack sets buildpack to auto-detected (ruby)")
    46  				session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    47  					PushCommandName, appName,
    48  					"-b", "null",
    49  				)
    50  				Eventually(session).Should(Say(`\-\s+buildpack:\s+staticfile_buildpack`))
    51  				Consistently(session).ShouldNot(Say(`\+\s+buildpack:`))
    52  				Eventually(session).Should(Say("Ruby Buildpack"))
    53  				Eventually(session).Should(Exit(0))
    54  
    55  				session = helpers.CF("app", appName)
    56  				Eventually(session).Should(Say(`buildpack:\s+ruby`))
    57  				Eventually(session).Should(Exit(0))
    58  
    59  				By("pushing a ruby app with a static buildpack sets buildpack to static")
    60  				session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    61  					PushCommandName, appName,
    62  					"-b", "staticfile_buildpack",
    63  				)
    64  				Eventually(session).Should(Say("Staticfile Buildpack"))
    65  				Eventually(session).Should(Exit(0))
    66  
    67  				session = helpers.CF("app", appName)
    68  				Eventually(session).Should(Say("buildpack:\\s+staticfile_buildpack"))
    69  				Eventually(session).Should(Exit(0))
    70  
    71  				By("pushing a ruby app with a default buildpack sets buildpack to auto-detected (ruby)")
    72  				session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir},
    73  					PushCommandName, appName,
    74  					"-b", "default",
    75  				)
    76  				Eventually(session).Should(Say(`\-\s+buildpack:\s+staticfile_buildpack`))
    77  				Consistently(session).ShouldNot(Say(`\+\s+buildpack:`))
    78  				Eventually(session).Should(Say("Ruby Buildpack"))
    79  				Eventually(session).Should(Exit(0))
    80  
    81  				session = helpers.CF("app", appName)
    82  				Eventually(session).Should(Say(`buildpack:\s+ruby`))
    83  				Eventually(session).Should(Exit(0))
    84  
    85  			})
    86  		})
    87  	})
    88  })