github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+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/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 symlink path", func() { 18 var ( 19 appName string 20 runningDir string 21 symlinkedPath string 22 ) 23 24 BeforeEach(func() { 25 appName = helpers.NewAppName() 26 27 var err error 28 runningDir, err = ioutil.TempDir("", "push-with-symlink") 29 Expect(err).ToNot(HaveOccurred()) 30 symlinkedPath = filepath.Join(runningDir, "symlink-dir") 31 }) 32 33 AfterEach(func() { 34 Expect(os.RemoveAll(runningDir)).ToNot(HaveOccurred()) 35 }) 36 37 Context("push with flag options", func() { 38 Context("when pushing from a symlinked current directory", func() { 39 It("should push with the absolute path of the app", func() { 40 helpers.WithHelloWorldApp(func(dir string) { 41 Expect(os.Symlink(dir, symlinkedPath)).ToNot(HaveOccurred()) 42 43 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: symlinkedPath}, PushCommandName, appName) 44 Eventually(session).Should(Say("path:\\s+%s", regexp.QuoteMeta(dir))) 45 Eventually(session).Should(Exit(0)) 46 }) 47 }) 48 }) 49 50 Context("when pushing a symlinked path with the '-p' flag", func() { 51 It("should push with the absolute path of the app", func() { 52 helpers.WithHelloWorldApp(func(dir string) { 53 Expect(os.Symlink(dir, symlinkedPath)).ToNot(HaveOccurred()) 54 55 session := helpers.CF(PushCommandName, appName, "-p", symlinkedPath) 56 Eventually(session).Should(Say("path:\\s+%s", regexp.QuoteMeta(dir))) 57 Eventually(session).Should(Exit(0)) 58 }) 59 }) 60 }) 61 62 Context("when pushing an symlinked archive with the '-p' flag", func() { 63 var archive string 64 65 BeforeEach(func() { 66 helpers.WithHelloWorldApp(func(appDir string) { 67 tmpfile, err := ioutil.TempFile("", "push-archive-integration") 68 Expect(err).ToNot(HaveOccurred()) 69 archive = tmpfile.Name() 70 Expect(tmpfile.Close()).ToNot(HaveOccurred()) 71 72 err = helpers.Zipit(appDir, archive, "") 73 Expect(err).ToNot(HaveOccurred()) 74 }) 75 }) 76 77 AfterEach(func() { 78 Expect(os.RemoveAll(archive)).ToNot(HaveOccurred()) 79 }) 80 81 It("should push with the absolute path of the archive", func() { 82 Expect(os.Symlink(archive, symlinkedPath)).ToNot(HaveOccurred()) 83 84 session := helpers.CF(PushCommandName, appName, "-p", symlinkedPath) 85 Eventually(session).Should(Say("path:\\s+%s", regexp.QuoteMeta(archive))) 86 Eventually(session).Should(Exit(0)) 87 }) 88 }) 89 }) 90 91 Context("push with a single app manifest", func() { 92 Context("when the path property is a symlinked path", func() { 93 It("should push with the absolute path of the app", func() { 94 helpers.WithHelloWorldApp(func(dir string) { 95 Expect(os.Symlink(dir, symlinkedPath)).ToNot(HaveOccurred()) 96 97 helpers.WriteManifest(filepath.Join(runningDir, "manifest.yml"), map[string]interface{}{ 98 "applications": []map[string]string{ 99 { 100 "name": appName, 101 "path": symlinkedPath, 102 }, 103 }, 104 }) 105 106 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: runningDir}, PushCommandName) 107 Eventually(session).Should(Say("path:\\s+%s", regexp.QuoteMeta(dir))) 108 Eventually(session).Should(Exit(0)) 109 }) 110 }) 111 }) 112 }) 113 })