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