github.com/sleungcy-sap/cli@v7.1.0+incompatible/integration/v6/isolated/isolation_segments_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("isolation-segments command", func() { 12 Describe("help", func() { 13 When("--help flag is set", func() { 14 It("Displays command usage to output", func() { 15 session := helpers.CF("isolation-segments", "--help") 16 Eventually(session).Should(Say("NAME:")) 17 Eventually(session).Should(Say("isolation-segments - List all isolation segments")) 18 Eventually(session).Should(Say("USAGE:")) 19 Eventually(session).Should(Say("cf isolation-segments")) 20 Eventually(session).Should(Say("SEE ALSO:")) 21 Eventually(session).Should(Say("create-isolation-segment, enable-org-isolation")) 22 Eventually(session).Should(Exit(0)) 23 }) 24 }) 25 }) 26 27 When("the environment is not setup correctly", func() { 28 It("fails with the appropriate errors", func() { 29 helpers.CheckEnvironmentTargetedCorrectly(false, false, ReadOnlyOrg, "isolation-segments") 30 }) 31 }) 32 33 When("the environment is set up correctly", func() { 34 BeforeEach(func() { 35 helpers.LoginCF() 36 }) 37 38 When("there are some isolation segments", func() { 39 var isolationSegment1 string // No orgs assigned 40 var isolationSegment2 string // One org assigned 41 var isolationSegment3 string // Many orgs assigned 42 var org1 string 43 var org2 string 44 45 BeforeEach(func() { 46 org1 = helpers.NewOrgName() 47 org2 = helpers.NewOrgName() 48 helpers.CreateOrg(org1) 49 helpers.CreateOrg(org2) 50 51 isolationSegment1 = helpers.NewIsolationSegmentName() 52 isolationSegment2 = helpers.NewIsolationSegmentName() 53 isolationSegment3 = helpers.NewIsolationSegmentName() 54 55 Eventually(helpers.CF("create-isolation-segment", isolationSegment1)).Should(Exit(0)) 56 Eventually(helpers.CF("create-isolation-segment", isolationSegment2)).Should(Exit(0)) 57 Eventually(helpers.CF("create-isolation-segment", isolationSegment3)).Should(Exit(0)) 58 Eventually(helpers.CF("enable-org-isolation", org1, isolationSegment2)).Should(Exit(0)) 59 Eventually(helpers.CF("enable-org-isolation", org1, isolationSegment3)).Should(Exit(0)) 60 Eventually(helpers.CF("enable-org-isolation", org2, isolationSegment3)).Should(Exit(0)) 61 }) 62 63 AfterEach(func() { 64 helpers.QuickDeleteOrg(org1) 65 helpers.QuickDeleteOrg(org2) 66 }) 67 68 It("returns an ok and displays the table", func() { 69 userName, _ := helpers.GetCredentials() 70 session := helpers.CF("isolation-segments") 71 Eventually(session).Should(Say("Getting isolation segments as %s...", userName)) 72 Eventually(session).Should(Say("OK")) 73 Eventually(session).Should(Say(`name\s+orgs`)) 74 Eventually(session).Should(Say("shared")) 75 Eventually(session).Should(Say(`%s\s+`, isolationSegment1)) 76 Eventually(session).Should(Say(`%s\s+%s`, isolationSegment2, org1)) 77 Eventually(session).Should(Say(`%s\s+%s, %s`, isolationSegment3, org1, org2)) 78 Eventually(session).Should(Exit(0)) 79 }) 80 }) 81 }) 82 })