github.com/randomtask1155/cli@v6.41.1-0.20181227003417-a98eed78cbde+incompatible/integration/v6/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 . "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 helpers.SkipIfVersionLessThan(ccversion.MinVersionSymlinkedFilesV2) 26 appName = helpers.NewAppName() 27 28 var err error 29 runningDir, err = ioutil.TempDir("", "push-with-symlink") 30 Expect(err).ToNot(HaveOccurred()) 31 symlinkedPath = filepath.Join(runningDir, "symlink-dir") 32 }) 33 34 AfterEach(func() { 35 Expect(os.RemoveAll(runningDir)).ToNot(HaveOccurred()) 36 }) 37 38 Context("push with flag options", func() { 39 When("pushing from a symlinked current directory", func() { 40 It("should push with the absolute path of the app", func() { 41 helpers.WithHelloWorldApp(func(dir string) { 42 Expect(os.Symlink(dir, symlinkedPath)).ToNot(HaveOccurred()) 43 44 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: symlinkedPath}, PushCommandName, appName) 45 Eventually(session).Should(Say(`path:\s+(\/private)?%s`, regexp.QuoteMeta(dir))) 46 Eventually(session).Should(Exit(0)) 47 }) 48 }) 49 }) 50 51 When("pushing a symlinked path with the '-p' flag", func() { 52 It("should push with the absolute path of the app", func() { 53 helpers.WithHelloWorldApp(func(dir string) { 54 Expect(os.Symlink(dir, symlinkedPath)).ToNot(HaveOccurred()) 55 56 session := helpers.CF(PushCommandName, appName, "-p", symlinkedPath) 57 Eventually(session).Should(Say(`path:\s+(\/private)?%s`, regexp.QuoteMeta(dir))) 58 Eventually(session).Should(Exit(0)) 59 }) 60 }) 61 }) 62 63 When("pushing an symlinked archive with the '-p' flag", func() { 64 var archive string 65 66 BeforeEach(func() { 67 helpers.WithHelloWorldApp(func(appDir string) { 68 tmpfile, err := ioutil.TempFile("", "push-archive-integration") 69 Expect(err).ToNot(HaveOccurred()) 70 archive = tmpfile.Name() 71 Expect(tmpfile.Close()).ToNot(HaveOccurred()) 72 73 err = helpers.Zipit(appDir, archive, "") 74 Expect(err).ToNot(HaveOccurred()) 75 }) 76 }) 77 78 AfterEach(func() { 79 Expect(os.RemoveAll(archive)).ToNot(HaveOccurred()) 80 }) 81 82 It("should push with the absolute path of the archive", func() { 83 Expect(os.Symlink(archive, symlinkedPath)).ToNot(HaveOccurred()) 84 85 session := helpers.CF(PushCommandName, appName, "-p", symlinkedPath) 86 Eventually(session).Should(Say(`path:\s+(\/private)?%s`, regexp.QuoteMeta(archive))) 87 Eventually(session).Should(Exit(0)) 88 }) 89 }) 90 91 Context("push with a single app manifest", func() { 92 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+(\/private)?%s`, regexp.QuoteMeta(dir))) 108 Eventually(session).Should(Exit(0)) 109 }) 110 }) 111 }) 112 }) 113 }) 114 })