github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/integration/push/no_route_test.go (about) 1 package push 2 3 import ( 4 "path/filepath" 5 6 "code.cloudfoundry.org/cli/integration/helpers" 7 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/gomega" 10 . "github.com/onsi/gomega/gbytes" 11 . "github.com/onsi/gomega/gexec" 12 ) 13 14 var _ = Describe("no-route property", func() { 15 var ( 16 appName string 17 ) 18 19 BeforeEach(func() { 20 appName = helpers.NewAppName() 21 }) 22 23 Context("when pushing with a manifest", func() { 24 Context("when pushing a new app", func() { 25 It("does not create any routes", func() { 26 helpers.WithHelloWorldApp(func(dir string) { 27 helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{ 28 "applications": []map[string]interface{}{ 29 { 30 "name": appName, 31 "no-route": true, 32 }, 33 }, 34 }) 35 36 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start") 37 Eventually(session).Should(Say("\\+\\s+name:\\s+%s", appName)) 38 Consistently(session).ShouldNot(Say("Mapping routes\\.\\.\\.")) 39 Eventually(session).Should(Exit(0)) 40 }) 41 42 session := helpers.CF("app", appName) 43 Eventually(session).Should(Say("name:\\s+%s", appName)) 44 Eventually(session).Should(Say("(?m)routes:\\s+\n")) 45 Eventually(session).Should(Exit(0)) 46 }) 47 }) 48 49 Context("when the app already exists", func() { 50 BeforeEach(func() { 51 helpers.WithHelloWorldApp(func(dir string) { 52 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--no-start") 53 Eventually(session).Should(Exit(0)) 54 }) 55 }) 56 57 It("unmaps any existing routes", func() { 58 helpers.WithHelloWorldApp(func(dir string) { 59 helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{ 60 "applications": []map[string]interface{}{ 61 { 62 "name": appName, 63 "no-route": true, 64 }, 65 }, 66 }) 67 68 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start") 69 Eventually(session).Should(Say("\\s+name:\\s+%s", appName)) 70 Eventually(session).Should(Say("(?i)\\-\\s+%s.%s", appName, defaultSharedDomain())) 71 Eventually(session).Should(Say("Unmapping routes\\.\\.\\.")) 72 Eventually(session).Should(Exit(0)) 73 }) 74 75 session := helpers.CF("app", appName) 76 Eventually(session).Should(Say("name:\\s+%s", appName)) 77 Eventually(session).Should(Say("(?m)routes:\\s+\n")) 78 Eventually(session).Should(Exit(0)) 79 }) 80 }) 81 82 It("does not create any routes", func() { 83 helpers.WithHelloWorldApp(func(dir string) { 84 helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{ 85 "applications": []map[string]interface{}{ 86 { 87 "name": appName, 88 "no-route": true, 89 "routes": []map[string]string{ 90 map[string]string{ 91 "route": "example.com", 92 }, 93 }, 94 }, 95 }, 96 }) 97 98 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-start") 99 Eventually(session.Err).Should(Say("Application %s cannot use the combination of properties: no-route, routes", appName)) 100 Eventually(session).Should(Exit(1)) 101 }) 102 }) 103 }) 104 105 Context("when pushing with no manifest", func() { 106 Context("when pushing a new app", func() { 107 It("does not create any routes", func() { 108 helpers.WithHelloWorldApp(func(dir string) { 109 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--no-route", "--no-start") 110 Eventually(session).Should(Say("\\+\\s+name:\\s+%s", appName)) 111 Consistently(session).ShouldNot(Say("Mapping routes\\.\\.\\.")) 112 Eventually(session).Should(Exit(0)) 113 }) 114 115 session := helpers.CF("app", appName) 116 Eventually(session).Should(Say("name:\\s+%s", appName)) 117 Eventually(session).Should(Say("(?m)routes:\\s+\n")) 118 Eventually(session).Should(Exit(0)) 119 }) 120 }) 121 122 Context("when the app already exists", func() { 123 BeforeEach(func() { 124 helpers.WithHelloWorldApp(func(dir string) { 125 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--no-start") 126 Eventually(session).Should(Exit(0)) 127 }) 128 }) 129 130 It("unmaps any existing routes", func() { 131 helpers.WithHelloWorldApp(func(dir string) { 132 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--no-route", "--no-start") 133 Eventually(session).Should(Say("\\s+name:\\s+%s", appName)) 134 Eventually(session).Should(Say("(?i)\\-\\s+%s.%s", appName, defaultSharedDomain())) 135 Eventually(session).Should(Say("Unmapping routes\\.\\.\\.")) 136 Eventually(session).Should(Exit(0)) 137 }) 138 139 session := helpers.CF("app", appName) 140 Eventually(session).Should(Say("name:\\s+%s", appName)) 141 Eventually(session).Should(Say("(?m)routes:\\s+\n")) 142 Eventually(session).Should(Exit(0)) 143 }) 144 }) 145 }) 146 147 Context("when pushing with flags and manifest", func() { 148 It("does not create the routes", func() { 149 helpers.WithHelloWorldApp(func(dir string) { 150 helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{ 151 "applications": []map[string]interface{}{ 152 { 153 "name": appName, 154 "routes": []map[string]string{ 155 map[string]string{ 156 "route": "example.com", 157 }, 158 }, 159 }, 160 }, 161 }) 162 163 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, "--no-route", "--no-start") 164 Eventually(session).Should(Say("\\+\\s+name:\\s+%s", appName)) 165 Eventually(session).Should(Exit(0)) 166 }) 167 168 session := helpers.CF("app", appName) 169 Eventually(session).Should(Say("name:\\s+%s", appName)) 170 Eventually(session).Should(Say("(?m)routes:\\s+\n")) 171 Eventually(session).Should(Exit(0)) 172 }) 173 }) 174 })