github.com/lukasheimann/cloudfoundrycli@v7.1.0+incompatible/integration/v7/push/resource_matching_test.go (about)

     1  package push
     2  
     3  import (
     4  	"fmt"
     5  	"io/ioutil"
     6  	"path/filepath"
     7  	"strings"
     8  	"time"
     9  
    10  	"code.cloudfoundry.org/cli/integration/helpers"
    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("resource matching", func() {
    18  	var (
    19  		appName string
    20  	)
    21  
    22  	BeforeEach(func() {
    23  		appName = helpers.NewAppName()
    24  	})
    25  
    26  	When("the app has some of it's resources matched", func() {
    27  		It("uploads the unmatched resources", func() {
    28  			helpers.WithHelloWorldApp(func(dir string) {
    29  				tempfile := filepath.Join(dir, "ignore.html")
    30  				err := ioutil.WriteFile(tempfile, []byte(fmt.Sprintf("hello world %s %s", time.Now(), strings.Repeat("a", 65*1024))), 0666)
    31  				Expect(err).ToNot(HaveOccurred())
    32  
    33  				session := helpers.DebugCustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--no-start")
    34  				Eventually(session.Err).Should(Say("zipped_file_count=3"))
    35  				Eventually(session).Should(Exit(0))
    36  
    37  				session = helpers.DebugCustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "-b", "staticfile_buildpack")
    38  				Eventually(session.Err).Should(Say("zipped_file_count=2"))
    39  				Eventually(session).Should(Exit(0))
    40  			})
    41  
    42  			session := helpers.CF("app", appName)
    43  			Eventually(session).Should(Say(`name:\s+%s`, appName))
    44  			Eventually(session).Should(Exit(0))
    45  		})
    46  	})
    47  
    48  	When("the app has all of it's resources matched", func() {
    49  		It("does not display the progress bar", func() {
    50  			// Skip("until #164837999 is complete")
    51  			helpers.WithNoResourceMatchedApp(func(dir string) {
    52  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--no-start")
    53  				Eventually(session).Should(Say(`\s+name:\s+%s`, appName))
    54  				Eventually(session).Should(Exit(0))
    55  
    56  				session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "-b", "staticfile_buildpack")
    57  				Eventually(session).Should(Say("All files found in remote cache; nothing to upload."))
    58  				Eventually(session).Should(Say(`\s+name:\s+%s`, appName))
    59  				Eventually(session).Should(Exit(0))
    60  			})
    61  
    62  			session := helpers.CF("app", appName)
    63  			Eventually(session).Should(Say(`name:\s+%s`, appName))
    64  			Eventually(session).Should(Exit(0))
    65  		})
    66  	})
    67  
    68  	When("the app has only empty files", func() {
    69  		It("skips resource matching", func() {
    70  			helpers.WithEmptyFilesApp(func(dir string) {
    71  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--no-start")
    72  				Eventually(session).Should(Say(`\s+name:\s+%s`, appName))
    73  				Eventually(session).Should(Exit(0))
    74  			})
    75  		})
    76  	})
    77  })