github.com/rakutentech/cli@v6.12.5-0.20151006231303-24468b65536e+incompatible/cf/requirements/targeted_organization_test.go (about) 1 package requirements_test 2 3 import ( 4 "github.com/cloudfoundry/cli/cf/configuration/core_config" 5 "github.com/cloudfoundry/cli/cf/models" 6 7 testassert "github.com/cloudfoundry/cli/testhelpers/assert" 8 testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" 9 testterm "github.com/cloudfoundry/cli/testhelpers/terminal" 10 11 . "github.com/cloudfoundry/cli/cf/requirements" 12 . "github.com/cloudfoundry/cli/testhelpers/matchers" 13 . "github.com/onsi/ginkgo" 14 . "github.com/onsi/gomega" 15 ) 16 17 var _ = Describe("TargetedOrganizationRequirement", func() { 18 var ( 19 ui *testterm.FakeUI 20 config core_config.ReadWriter 21 ) 22 23 BeforeEach(func() { 24 ui = new(testterm.FakeUI) 25 config = testconfig.NewRepositoryWithDefaults() 26 }) 27 28 Context("when the user has an org targeted", func() { 29 It("succeeds", func() { 30 req := NewTargetedOrgRequirement(ui, config) 31 success := req.Execute() 32 Expect(success).To(BeTrue()) 33 }) 34 }) 35 36 Context("when the user does not have an org targeted", func() { 37 It("fails", func() { 38 config.SetOrganizationFields(models.OrganizationFields{}) 39 40 testassert.AssertPanic(testterm.QuietPanic, func() { 41 NewTargetedOrgRequirement(ui, config).Execute() 42 }) 43 44 Expect(ui.Outputs).To(ContainSubstrings( 45 []string{"FAILED"}, 46 []string{"No org targeted"}, 47 )) 48 }) 49 }) 50 })