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