github.com/ablease/cli@v6.37.1-0.20180613014814-3adbb7d7fb19+incompatible/integration/push/symlink_test.go (about) 1 package push 2 3 import ( 4 "io/ioutil" 5 "os" 6 "path/filepath" 7 "regexp" 8 9 "code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" 10 "code.cloudfoundry.org/cli/integration/helpers" 11 12 . "github.com/onsi/ginkgo" 13 . "github.com/onsi/gomega" 14 . "github.com/onsi/gomega/gbytes" 15 . "github.com/onsi/gomega/gexec" 16 ) 17 18 var _ = Describe("push with symlink path", func() { 19 var ( 20 appName string 21 runningDir string 22 symlinkedPath string 23 ) 24 25 BeforeEach(func() { 26 helpers.SkipIfVersionLessThan(ccversion.MinVersionSymlinkedFilesV2) 27 appName = helpers.NewAppName() 28 29 var err error 30 runningDir, err = ioutil.TempDir("", "push-with-symlink") 31 Expect(err).ToNot(HaveOccurred()) 32 symlinkedPath = filepath.Join(runningDir, "symlink-dir") 33 }) 34 35 AfterEach(func() { 36 Expect(os.RemoveAll(runningDir)).ToNot(HaveOccurred()) 37 }) 38 39 Context("push with flag options", func() { 40 Context("when pushing from a symlinked current directory", func() { 41 It("should push with the absolute path of the app", func() { 42 helpers.WithHelloWorldApp(func(dir string) { 43 Expect(os.Symlink(dir, symlinkedPath)).ToNot(HaveOccurred()) 44 45 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: symlinkedPath}, PushCommandName, appName) 46 Eventually(session).Should(Say("path:\\s+(\\/private)?%s", regexp.QuoteMeta(dir))) 47 Eventually(session).Should(Exit(0)) 48 }) 49 }) 50 }) 51 52 Context("when pushing a symlinked path with the '-p' flag", func() { 53 It("should push with the absolute path of the app", func() { 54 helpers.WithHelloWorldApp(func(dir string) { 55 Expect(os.Symlink(dir, symlinkedPath)).ToNot(HaveOccurred()) 56 57 session := helpers.CF(PushCommandName, appName, "-p", symlinkedPath) 58 Eventually(session).Should(Say("path:\\s+(\\/private)?%s", regexp.QuoteMeta(dir))) 59 Eventually(session).Should(Exit(0)) 60 }) 61 }) 62 }) 63 64 Context("when pushing an symlinked archive with the '-p' flag", func() { 65 var archive string 66 67 BeforeEach(func() { 68 helpers.WithHelloWorldApp(func(appDir string) { 69 tmpfile, err := ioutil.TempFile("", "push-archive-integration") 70 Expect(err).ToNot(HaveOccurred()) 71 archive = tmpfile.Name() 72 Expect(tmpfile.Close()).ToNot(HaveOccurred()) 73 74 err = helpers.Zipit(appDir, archive, "") 75 Expect(err).ToNot(HaveOccurred()) 76 }) 77 }) 78 79 AfterEach(func() { 80 Expect(os.RemoveAll(archive)).ToNot(HaveOccurred()) 81 }) 82 83 It("should push with the absolute path of the archive", func() { 84 Expect(os.Symlink(archive, symlinkedPath)).ToNot(HaveOccurred()) 85 86 session := helpers.CF(PushCommandName, appName, "-p", symlinkedPath) 87 Eventually(session).Should(Say("path:\\s+(\\/private)?%s", regexp.QuoteMeta(archive))) 88 Eventually(session).Should(Exit(0)) 89 }) 90 }) 91 92 Context("push with a single app manifest", func() { 93 Context("when the path property is a symlinked path", func() { 94 It("should push with the absolute path of the app", func() { 95 helpers.WithHelloWorldApp(func(dir string) { 96 Expect(os.Symlink(dir, symlinkedPath)).ToNot(HaveOccurred()) 97 98 helpers.WriteManifest(filepath.Join(runningDir, "manifest.yml"), map[string]interface{}{ 99 "applications": []map[string]string{ 100 { 101 "name": appName, 102 "path": symlinkedPath, 103 }, 104 }, 105 }) 106 107 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: runningDir}, PushCommandName) 108 Eventually(session).Should(Say("path:\\s+(\\/private)?%s", regexp.QuoteMeta(dir))) 109 Eventually(session).Should(Exit(0)) 110 }) 111 }) 112 }) 113 }) 114 }) 115 })