github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/v7/isolated/check_route_command_test.go (about) 1 package isolated 2 3 import ( 4 . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" 5 "code.cloudfoundry.org/cli/integration/helpers" 6 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/gomega" 8 . "github.com/onsi/gomega/gbytes" 9 . "github.com/onsi/gomega/gexec" 10 ) 11 12 var _ = Describe("check-route command", func() { 13 Context("Help", func() { 14 It("appears in cf help -a", func() { 15 session := helpers.CF("help", "-a") 16 Eventually(session).Should(Exit(0)) 17 Expect(session).To(HaveCommandInCategoryWithDescription("check-route", "ROUTES", "Perform a check to determine whether a route currently exists or not")) 18 }) 19 20 It("displays the help information", func() { 21 session := helpers.CF("check-route", "--help") 22 Eventually(session).Should(Say(`NAME:`)) 23 Eventually(session).Should(Say(`check-route - Perform a check to determine whether a route currently exists or not\n`)) 24 Eventually(session).Should(Say(`\n`)) 25 26 Eventually(session).Should(Say(`USAGE:`)) 27 Eventually(session).Should(Say(`cf check-route DOMAIN \[--hostname HOSTNAME\] \[--path PATH\]\n`)) 28 Eventually(session).Should(Say(`\n`)) 29 30 Eventually(session).Should(Say(`EXAMPLES:`)) 31 Eventually(session).Should(Say(`cf check-route example.com # example.com`)) 32 Eventually(session).Should(Say(`cf check-route example.com -n myhost --path foo # myhost.example.com/foo`)) 33 Eventually(session).Should(Say(`cf check-route example.com --path foo # example.com/foo`)) 34 Eventually(session).Should(Say(`\n`)) 35 36 Eventually(session).Should(Say(`OPTIONS:`)) 37 Eventually(session).Should(Say(`--hostname, -n\s+Hostname used to identify the HTTP route`)) 38 Eventually(session).Should(Say(`--path\s+Path for the route`)) 39 Eventually(session).Should(Say(`\n`)) 40 41 Eventually(session).Should(Say(`SEE ALSO:`)) 42 Eventually(session).Should(Say(`create-route, delete-route, routes`)) 43 44 Eventually(session).Should(Exit(0)) 45 }) 46 }) 47 48 When("the environment is not setup correctly", func() { 49 It("fails with the appropriate errors", func() { 50 helpers.CheckEnvironmentTargetedCorrectly(true, false, ReadOnlyOrg, "check-route", "some-domain") 51 }) 52 }) 53 54 When("the environment is set up correctly", func() { 55 var ( 56 orgName string 57 spaceName string 58 ) 59 60 BeforeEach(func() { 61 orgName = helpers.NewOrgName() 62 spaceName = helpers.NewSpaceName() 63 64 helpers.SetupCF(orgName, spaceName) 65 }) 66 67 AfterEach(func() { 68 helpers.QuickDeleteOrg(orgName) 69 }) 70 71 When("the domain exists", func() { 72 var ( 73 domainName string 74 ) 75 76 BeforeEach(func() { 77 domainName = helpers.NewDomainName() 78 }) 79 80 When("the route exists", func() { 81 var ( 82 domain helpers.Domain 83 hostname string 84 ) 85 86 BeforeEach(func() { 87 domain = helpers.NewDomain(orgName, domainName) 88 hostname = "key-lime-pie" 89 domain.CreatePrivate() 90 Eventually(helpers.CF("create-route", domainName, "--hostname", hostname)).Should(Exit(0)) 91 }) 92 93 AfterEach(func() { 94 domain.Delete() 95 }) 96 97 It("tells the user the route exists and exits without failing", func() { 98 session := helpers.CF("check-route", domainName, "--hostname", hostname) 99 Eventually(session).Should(Say(`Checking for route\.\.\.`)) 100 Eventually(session).Should(Say(`Route '%s\.%s' does exist\.`, hostname, domainName)) 101 Eventually(session).Should(Say(`OK`)) 102 Eventually(session).Should(Exit(0)) 103 }) 104 }) 105 106 When("the route does not already exist", func() { 107 var domain helpers.Domain 108 109 BeforeEach(func() { 110 domain = helpers.NewDomain(orgName, domainName) 111 domain.Create() 112 }) 113 114 AfterEach(func() { 115 domain.Delete() 116 }) 117 118 When("no flags are used", func() { 119 It("checks the route", func() { 120 session := helpers.CF("check-route", domainName) 121 Eventually(session).Should(Say(`Checking for route\.\.\.`)) 122 Eventually(session).Should(Say(`Route '%s' does not exist\.`, domainName)) 123 Eventually(session).Should(Exit(0)) 124 }) 125 }) 126 127 When("passing in a hostname", func() { 128 It("checks the route with the hostname", func() { 129 hostname := "tiramisu" 130 session := helpers.CF("check-route", domainName, "-n", hostname) 131 Eventually(session).Should(Say(`Checking for route\.\.\.`)) 132 Eventually(session).Should(Say(`Route '%s\.%s' does not exist\.`, hostname, domainName)) 133 Eventually(session).Should(Exit(0)) 134 }) 135 }) 136 137 When("passing in hostname and path with a leading '/'", func() { 138 It("checks the route with hostname and path", func() { 139 hostname := "tiramisu" 140 pathString := "/recipes" 141 session := helpers.CF("check-route", domainName, "-n", hostname, "--path", pathString) 142 Eventually(session).Should(Say(`Checking for route\.\.\.`)) 143 Eventually(session).Should(Say(`Route '%s\.%s%s' does not exist\.`, hostname, domainName, pathString)) 144 Eventually(session).Should(Exit(0)) 145 }) 146 }) 147 148 When("passing in hostname and path without a leading '/'", func() { 149 It("checks the route with hostname and path", func() { 150 hostname := "tiramisu" 151 pathString := "more-recipes" 152 session := helpers.CF("check-route", domainName, "-n", hostname, "--path", pathString) 153 Eventually(session).Should(Say(`Checking for route\.\.\.`)) 154 Eventually(session).Should(Say(`Route '%s\.%s\/%s' does not exist\.`, hostname, domainName, pathString)) 155 Eventually(session).Should(Exit(0)) 156 }) 157 }) 158 }) 159 }) 160 161 When("the domain does not exist", func() { 162 It("displays error and exits 1", func() { 163 session := helpers.CF("check-route", "some-domain") 164 Eventually(session).Should(Say(`FAILED`)) 165 Eventually(session.Err).Should(Say(`Domain 'some-domain' not found.`)) 166 Eventually(session).Should(Exit(1)) 167 }) 168 }) 169 170 When("the domain is not specified", func() { 171 It("displays error and exits 1", func() { 172 session := helpers.CF("check-route") 173 Eventually(session.Err).Should(Say("Incorrect Usage: the required argument `DOMAIN` was not provided\n")) 174 Eventually(session.Err).Should(Say("\n")) 175 Eventually(session).Should(Say("NAME:\n")) 176 Eventually(session).Should(Exit(1)) 177 }) 178 }) 179 }) 180 })