github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/integration/v7/push/ignore_app_files_test.go (about) 1 package push 2 3 import ( 4 "io/ioutil" 5 "path/filepath" 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("ignoring files while gathering resources", func() { 16 var ( 17 firstApp string 18 ) 19 20 BeforeEach(func() { 21 firstApp = helpers.NewAppName() 22 }) 23 24 When("the .cfignore file is in the app source directory", func() { 25 When("the .cfignore file doesn't exclude any files", func() { 26 It("pushes all the files", func() { 27 helpers.WithHelloWorldApp(func(dir string) { 28 file1 := filepath.Join(dir, "file1") 29 err := ioutil.WriteFile(file1, nil, 0666) 30 Expect(err).ToNot(HaveOccurred()) 31 32 file2 := filepath.Join(dir, "file2") 33 err = ioutil.WriteFile(file2, nil, 0666) 34 Expect(err).ToNot(HaveOccurred()) 35 36 cfIgnoreFilePath := filepath.Join(dir, ".cfignore") 37 err = ioutil.WriteFile(cfIgnoreFilePath, nil, 0666) 38 Expect(err).ToNot(HaveOccurred()) 39 40 session := helpers.DebugCustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, firstApp, "--no-start") 41 42 Eventually(session.Err).Should(Say("zipped_file_count=4")) 43 Eventually(session).Should(Exit(0)) 44 }) 45 }) 46 }) 47 48 When("the .cfignore file excludes some files", func() { 49 Context("ignored files are relative paths", func() { 50 It("does not push those files", func() { 51 helpers.WithHelloWorldApp(func(dir string) { 52 file1 := filepath.Join(dir, "file1") 53 err := ioutil.WriteFile(file1, nil, 0666) 54 Expect(err).ToNot(HaveOccurred()) 55 56 file2 := filepath.Join(dir, "file2") 57 err = ioutil.WriteFile(file2, nil, 0666) 58 Expect(err).ToNot(HaveOccurred()) 59 60 cfIgnoreFilePath := filepath.Join(dir, ".cfignore") 61 err = ioutil.WriteFile(cfIgnoreFilePath, []byte("file*"), 0666) 62 Expect(err).ToNot(HaveOccurred()) 63 64 session := helpers.DebugCustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, firstApp, "--no-start") 65 66 Eventually(session.Err).Should(Say("zipped_file_count=2")) 67 Eventually(session).Should(Exit(0)) 68 }) 69 }) 70 }) 71 72 Context("with absolute paths - where '/' == appDir", func() { 73 It("does not push those files", func() { 74 helpers.WithHelloWorldApp(func(dir string) { 75 file1 := filepath.Join(dir, "file1") 76 err := ioutil.WriteFile(file1, nil, 0666) 77 Expect(err).ToNot(HaveOccurred()) 78 79 file2 := filepath.Join(dir, "file2") 80 err = ioutil.WriteFile(file2, nil, 0666) 81 Expect(err).ToNot(HaveOccurred()) 82 83 cfIgnoreFilePath := filepath.Join(dir, ".cfignore") 84 err = ioutil.WriteFile(cfIgnoreFilePath, []byte("/file*"), 0666) 85 Expect(err).ToNot(HaveOccurred()) 86 87 session := helpers.DebugCustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, firstApp, "--no-start") 88 89 Eventually(session.Err).Should(Say("zipped_file_count=2")) 90 Eventually(session).Should(Exit(0)) 91 }) 92 }) 93 }) 94 }) 95 }) 96 97 When("the CF_TRACE file is in the app source directory", func() { 98 It("does not push it", func() { 99 helpers.WithHelloWorldApp(func(dir string) { 100 traceFilePath := filepath.Join(dir, "i-am-trace.txt") 101 err := ioutil.WriteFile(traceFilePath, nil, 0666) 102 Expect(err).ToNot(HaveOccurred()) 103 104 session := helpers.DebugCustomCF(helpers.CFEnv{ 105 WorkingDirectory: dir, 106 EnvVars: map[string]string{ 107 "CF_TRACE": traceFilePath, 108 }, 109 }, 110 PushCommandName, firstApp, "--no-start", 111 ) 112 113 Eventually(session.Err).Should(Say("zipped_file_count=2")) 114 Eventually(session).Should(Exit(0)) 115 }) 116 }) 117 }) 118 })