github.com/arunkumar7540/cli@v6.45.0+incompatible/integration/v7/isolated/routes_command_test.go (about) 1 package isolated 2 3 import ( 4 "code.cloudfoundry.org/cli/integration/helpers" 5 . "github.com/onsi/ginkgo" 6 . "github.com/onsi/gomega" 7 . "github.com/onsi/gomega/gbytes" 8 . "github.com/onsi/gomega/gexec" 9 ) 10 11 var _ = Describe("routes command", func() { 12 Context("Help", func() { 13 It("displays the help information", func() { 14 session := helpers.CF("routes", "--help") 15 Eventually(session).Should(Say(`NAME:`)) 16 Eventually(session).Should(Say(`routes - List all routes in the current space or the current organization\n`)) 17 Eventually(session).Should(Say(`\n`)) 18 19 Eventually(session).Should(Say(`USAGE:`)) 20 Eventually(session).Should(Say(`cf routes \[--orglevel\]\n`)) 21 Eventually(session).Should(Say(`\n`)) 22 23 Eventually(session).Should(Say(`OPTIONS:`)) 24 Eventually(session).Should(Say(`--orglevel\s+List all the routes for all spaces of current organization`)) 25 Eventually(session).Should(Say(`\n`)) 26 27 Eventually(session).Should(Say(`SEE ALSO:`)) 28 Eventually(session).Should(Say(`check-route, domains, map-route, unmap-route`)) 29 30 Eventually(session).Should(Exit(0)) 31 }) 32 }) 33 34 When("the environment is not setup correctly", func() { 35 It("fails with the appropriate errors", func() { 36 helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, "routes") 37 }) 38 }) 39 40 When("the environment is set up correctly", func() { 41 var ( 42 orgName string 43 spaceName string 44 ) 45 46 BeforeEach(func() { 47 orgName = helpers.NewOrgName() 48 spaceName = helpers.NewSpaceName() 49 50 helpers.SetupCF(orgName, spaceName) 51 }) 52 53 AfterEach(func() { 54 helpers.QuickDeleteOrg(orgName) 55 }) 56 57 var ( 58 userName string 59 ) 60 61 BeforeEach(func() { 62 userName, _ = helpers.GetCredentials() 63 }) 64 65 When("routes exist", func() { 66 var ( 67 userName string 68 domainName string 69 domain helpers.Domain 70 71 otherSpaceName string 72 ) 73 74 BeforeEach(func() { 75 otherSpaceName = helpers.NewSpaceName() 76 77 domainName = helpers.NewDomainName() 78 userName, _ = helpers.GetCredentials() 79 80 domain = helpers.NewDomain(orgName, domainName) 81 domain.CreatePrivate() 82 Eventually(helpers.CF("create-route", domainName, "--hostname", "route1")).Should(Exit(0)) 83 helpers.SetupCF(orgName, otherSpaceName) 84 Eventually(helpers.CF("create-route", domainName, "--hostname", "route2")).Should(Exit(0)) 85 helpers.SetupCF(orgName, spaceName) 86 }) 87 88 AfterEach(func() { 89 domain.Delete() 90 helpers.QuickDeleteSpace(otherSpaceName) 91 }) 92 93 It("lists all the routes", func() { 94 session := helpers.CF("routes") 95 Eventually(session).Should(Say(`Getting routes for org %s / space %s as %s\.\.\.`, orgName, spaceName, userName)) 96 Eventually(session).Should(Say(`%s\s+route1\s+%s`, spaceName, domainName)) 97 Eventually(session).Should(Exit(0)) 98 }) 99 100 When("fetching routes by org", func() { 101 It("lists all the routes in the org", func() { 102 session := helpers.CF("routes", "--orglevel") 103 Eventually(session).Should(Say(`Getting routes for org %s as %s\.\.\.`, orgName, userName)) 104 Eventually(session).Should(Say(`%s\s+route1\s+%s`, spaceName, domainName)) 105 Eventually(session).Should(Say(`%s\s+route2\s+%s`, otherSpaceName, domainName)) 106 Eventually(session).Should(Exit(0)) 107 }) 108 }) 109 }) 110 111 When("no routes exist", func() { 112 It("outputs a message about no routes existing", func() { 113 session := helpers.CF("routes") 114 Eventually(session).Should(Say(`Getting routes for org %s / space %s as %s\.\.\.`, orgName, spaceName, userName)) 115 Eventually(session).Should(Say("No routes found")) 116 Eventually(session).Should(Exit(0)) 117 }) 118 }) 119 }) 120 })