github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/v7/isolated/routes_command_test.go (about) 1 package isolated 2 3 import ( 4 . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" 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("routes command", func() { 14 Context("Help", func() { 15 It("appears in cf help -a", func() { 16 session := helpers.CF("help", "-a") 17 Eventually(session).Should(Exit(0)) 18 Expect(session).To(HaveCommandInCategoryWithDescription("routes", "ROUTES", "List all routes in the current space or the current organization")) 19 }) 20 21 It("displays the help information", func() { 22 session := helpers.CF("routes", "--help") 23 Eventually(session).Should(Say(`NAME:`)) 24 Eventually(session).Should(Say(`routes - List all routes in the current space or the current organization\n`)) 25 Eventually(session).Should(Say(`\n`)) 26 27 Eventually(session).Should(Say(`USAGE:`)) 28 Eventually(session).Should(Say(`cf routes \[--orglevel\]\n`)) 29 Eventually(session).Should(Say(`\n`)) 30 31 Eventually(session).Should(Say(`OPTIONS:`)) 32 Eventually(session).Should(Say(`--orglevel\s+List all the routes for all spaces of current organization`)) 33 Eventually(session).Should(Say(`\n`)) 34 35 Eventually(session).Should(Say(`SEE ALSO:`)) 36 Eventually(session).Should(Say(`check-route, domains, map-route, unmap-route`)) 37 38 Eventually(session).Should(Exit(0)) 39 }) 40 }) 41 42 When("the environment is not setup correctly", func() { 43 It("fails with the appropriate errors", func() { 44 helpers.CheckEnvironmentTargetedCorrectly(true, true, ReadOnlyOrg, "routes") 45 }) 46 }) 47 48 When("the environment is set up correctly", func() { 49 var ( 50 orgName string 51 spaceName string 52 userName string 53 appName1 string 54 appName2 string 55 ) 56 57 BeforeEach(func() { 58 orgName = helpers.NewOrgName() 59 spaceName = helpers.NewSpaceName() 60 61 helpers.SetupCF(orgName, spaceName) 62 userName, _ = helpers.GetCredentials() 63 }) 64 65 AfterEach(func() { 66 helpers.QuickDeleteOrg(orgName) 67 }) 68 69 When("routes exist", func() { 70 var ( 71 domainName string 72 domain helpers.Domain 73 74 otherSpaceName string 75 ) 76 77 BeforeEach(func() { 78 otherSpaceName = helpers.GenerateHigherName(helpers.NewSpaceName, spaceName) 79 80 domainName = helpers.NewDomainName() 81 82 domain = helpers.NewDomain(orgName, domainName) 83 appName1 = helpers.NewAppName() 84 Eventually(helpers.CF("create-app", appName1)).Should(Exit(0)) 85 domain.CreatePrivate() 86 Eventually(helpers.CF("map-route", appName1, domainName, "--hostname", "route1")).Should(Exit(0)) 87 Eventually(helpers.CF("map-route", appName1, domainName, "--hostname", "route1a")).Should(Exit(0)) 88 Eventually(helpers.CF("map-route", appName1, domainName, "--hostname", "route1b")).Should(Exit(0)) 89 Eventually(helpers.CF("set-label", "route", "route1b."+domainName, "env=prod")).Should(Exit(0)) 90 91 helpers.SetupCF(orgName, otherSpaceName) 92 appName2 = helpers.NewAppName() 93 Eventually(helpers.CF("create-app", appName2)).Should(Exit(0)) 94 Eventually(helpers.CF("map-route", appName2, domainName, "--hostname", "route2", "--path", "dodo")).Should(Exit(0)) 95 96 helpers.SetupCF(orgName, spaceName) 97 }) 98 99 AfterEach(func() { 100 domain.Delete() 101 helpers.QuickDeleteSpace(otherSpaceName) 102 }) 103 104 It("lists all the routes", func() { 105 session := helpers.CF("routes") 106 Eventually(session).Should(Exit(0)) 107 108 Expect(session).To(Say(`Getting routes for org %s / space %s as %s\.\.\.`, orgName, spaceName, userName)) 109 Expect(session).To(Say(`space\s+host\s+domain\s+path\s+apps`)) 110 Expect(session).To(Say(`%s\s+route1\s+%s\s+%s`, spaceName, domainName, appName1)) 111 Expect(session).To(Say(`%s\s+route1a\s+%s\s+%s`, spaceName, domainName, appName1)) 112 Expect(session).To(Say(`%s\s+route1b\s+%s\s+%s`, spaceName, domainName, appName1)) 113 Expect(session).ToNot(Say(`%s\s+route2\s+%s\s+%s`, spaceName, domainName, appName2)) 114 }) 115 116 It("lists all the routes by label", func() { 117 session := helpers.CF("routes", "--labels", "env in (prod)") 118 Eventually(session).Should(Exit(0)) 119 Expect(session).To(Say(`Getting routes for org %s / space %s as %s\.\.\.`, orgName, spaceName, userName)) 120 Expect(session).To(Say(`space\s+host\s+domain\s+path\s+apps`)) 121 Expect(session).ToNot(Say(`%s\s+route1\s+%s\s+%s`, spaceName, domainName, appName1)) 122 Expect(session).ToNot(Say(`%s\s+route1a\s+%s\s+%s`, spaceName, domainName, appName1)) 123 Expect(session).To(Say(`%s\s+route1b\s+%s\s+%s`, spaceName, domainName, appName1)) 124 Expect(session).ToNot(Say(`%s\s+route2\s+%s\s+%s`, spaceName, domainName, appName2)) 125 }) 126 127 When("fetching routes by org", func() { 128 It("lists all the routes in the org", func() { 129 session := helpers.CF("routes", "--orglevel") 130 Eventually(session).Should(Say(`Getting routes for org %s as %s\.\.\.`, orgName, userName)) 131 Eventually(session).Should(Say(`space\s+host\s+domain\s+path\s+apps`)) 132 133 Eventually(session).Should(Say(`%s\s+route1\s+%s\s+%s`, spaceName, domainName, appName1)) 134 Eventually(session).Should(Say(`%s\s+route2\s+%s\s+\/dodo\s+%s`, otherSpaceName, domainName, appName2)) 135 Eventually(session).Should(Exit(0)) 136 }) 137 }) 138 }) 139 140 When("no routes exist", func() { 141 It("outputs a message about no routes existing", func() { 142 session := helpers.CF("routes") 143 Eventually(session).Should(Say(`Getting routes for org %s / space %s as %s\.\.\.`, orgName, spaceName, userName)) 144 Eventually(session).Should(Say("No routes found")) 145 Eventually(session).Should(Exit(0)) 146 }) 147 }) 148 }) 149 })